Skip to content

Commit 68213a9

Browse files
authored
Update hyperlink terminology and add documentation generation (#89)
* config-libraries.go: Add documentation header * emitzig.go: Update hyperlink terminology * build.zig: Add documentation step * docs.yml: Add documentation generation workflow * README: Update badges and add demo * threading: Update hyperlink terminology * Update wrappers
1 parent e39420a commit 68213a9

File tree

2,533 files changed

+502093
-501942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,533 files changed

+502093
-501942
lines changed

.github/workflows/docs.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Documentation
3+
4+
on:
5+
push:
6+
branches: ["master"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
docs:
20+
environment:
21+
name: github-pages
22+
url: ${{ steps.deployment.outputs.page_url }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
- name: Setup Pages
28+
uses: actions/configure-pages@v5
29+
- name: Setup Zig
30+
uses: mlugg/setup-zig@v2
31+
with:
32+
version: 0.15.2
33+
- run: zig build docs
34+
- name: Upload artifact
35+
uses: actions/upload-pages-artifact@v4
36+
with:
37+
path: "zig-out/docs"
38+
- name: Deploy to GitHub Pages
39+
id: deployment
40+
uses: actions/deploy-pages@v4

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
![MIT License](https://img.shields.io/badge/License-MIT-green)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/rcalixte/libqt6zig)](https://goreportcard.com/report/github.com/rcalixte/libqt6zig)
8-
[![Static Badge](https://img.shields.io/badge/v0.15%20(stable)-f7a41d?logo=zig&logoColor=f7a41d&label=Zig)](https://ziglang.org/download/)
8+
[![Static Badge](https://img.shields.io/badge/v0.15%20(stable)-fdc009?logo=zig&logoColor=f7a41d&label=Zig)](https://ziglang.org/download/)
9+
10+
[![Documentation](https://github.com/rcalixte/libqt6zig/actions/workflows/docs.yml/badge.svg?branch=master)](https://github.com/rcalixte/libqt6zig/actions/workflows/docs.yml)
911
</div>
1012

1113
---
@@ -18,7 +20,7 @@ For previous libqt6zig versions supporting Qt 6.4+, there are branches correspon
1820

1921
This library is designed to be used as a dependency in a larger application and not as a standalone library. The versioning scheme used by this library is based on the Qt version used as a base to generate the bindings with an additional nod to the library revision number. Any breaking changes to the library will be reflected in the changelog.
2022

21-
These bindings are based on the [MIQT bindings for Go](https://github.com/mappu/miqt) that were released in August 2024. This library features support for Qt Core, GUI, Widgets, and Network as well as [additional Qt modules](https://doc.qt.io/qt-6/qt-additional-modules.html) such as Multimedia, Print Support, Spatial Audio, SQL, SVG, WebChannel, WebEngine, and more. In addition to Qt modules, this library also features support for third-party libraries such as [QCustomPlot](https://www.qcustomplot.com), [QScintilla](https://riverbankcomputing.com/software/qscintilla), various [KDE Frameworks](https://develop.kde.org/products/frameworks/), and others. This library has support for slots/signals, subclassing, custom widgets, async via Qt, etc. In addition, there is library tooling that provides native support for Qt Creator/Designer forms and the Qt Resource System. With improper handling, it is fairly easy to encounter segmentation faults or errors. Q3 of the [FAQ](#faq) is a decent entry point for newcomers in addition to the [examples](https://github.com/rcalixte/libqt6zig-examples). Please try out the library and start a [discussion](https://github.com/rcalixte/libqt6zig/discussions) if you have any questions or issues directly relevant to this library.
23+
These bindings are based on the [MIQT bindings for Go](https://github.com/mappu/miqt) that were released in August 2024. This library features support for Qt Core, GUI, Widgets, and Network as well as [additional Qt modules](https://doc.qt.io/qt-6/qt-additional-modules.html) such as Multimedia, Print Support, Spatial Audio, SQL, SVG, WebChannel, WebEngine, and more. In addition to Qt modules, this library also features support for third-party libraries such as [QCustomPlot](https://www.qcustomplot.com), [QScintilla](https://riverbankcomputing.com/software/qscintilla), various [KDE Frameworks](https://develop.kde.org/products/frameworks/), and others. This library has support for slots/signals, subclassing, custom widgets, async via Qt, etc. In addition, there is library tooling that provides native support for Qt Creator/Designer forms and the Qt Resource System. With improper handling, it is fairly easy to encounter segmentation faults or errors. Q3 of the [FAQ](#faq) is a decent entry point for newcomers in addition to the [examples](https://github.com/rcalixte/libqt6zig-examples) and the [demo application](https://github.com/rcalixte/libqt6zig-demo). Please try out the library and start a [discussion](https://github.com/rcalixte/libqt6zig/discussions) if you have any questions or issues directly relevant to this library.
2224

2325
---
2426

build.zig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,25 @@ pub fn build(b: *std.Build) !void {
192192
libqt6zig.addImport("qtzig", qtzig_types);
193193

194194
try b.modules.put("libqt6zig", libqt6zig);
195+
196+
// Documentation build step
197+
const docs_step = b.step("docs", "Emit libqt6zig documentation");
198+
const libqt6zig_docs = b.addLibrary(.{
199+
.name = "libqt6",
200+
.root_module = b.createModule(.{
201+
.target = target,
202+
.root_source_file = b.path("include/libqt6.zig"),
203+
}),
204+
});
205+
206+
const docs_install = b.addInstallDirectory(.{
207+
.source_dir = libqt6zig_docs.getEmittedDocs(),
208+
.install_dir = .prefix,
209+
.install_subdir = "docs",
210+
});
211+
212+
docs_step.dependOn(&docs_install.step);
213+
b.default_step.dependOn(docs_step);
195214
}
196215

197216
const is_bsd_host = switch (host_os) {

cmd/genbindings/config-libraries.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,38 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
811811
zigIncList = append(zigIncList, v)
812812
}
813813
sort.Strings(zigIncList)
814-
zigDefs := "// THIS FILE IS AUTOMATICALLY GENERATED\n\npub const C = @import(\"qtzig\");\n\n"
815-
zigDefs = zigDefs + strings.Join(zigIncList, "\n")
814+
zigDocs := `//! # Qt 6 for Zig
815+
//!
816+
//! ## Introduction
817+
//!
818+
//! This library provides Qt 6 bindings and wrappers for Zig. This online
819+
//! documentation is meant to simplify browsing the user-facing API for
820+
//! Zig, augmenting the official Qt documentation as well as auxiliary
821+
//! libraries that provide online documentation. The goal of this library
822+
//! is to facilitate single-language, cross-platform native desktop
823+
//! application development.
824+
//!
825+
//! This online documentation also includes third-party libraries in the Qt
826+
//! ecosystem such as [QCustomPlot](https://www.qcustomplot.com), [QScintilla](https://riverbankcomputing.com/software/qscintilla),
827+
//! various [KDE Frameworks](https://develop.kde.org/products/frameworks/), and others.
828+
//!
829+
//! For the [library tooling](https://github.com/rcalixte/libqt6zig?tab=readme-ov-file#tools), the documentation for each tool
830+
//! is available next to the tool's source code.
831+
//!
832+
//! ## Getting Started
833+
//!
834+
//! The main library documentation is outlined in the
835+
//! [table of contents](https://github.com/rcalixte/libqt6zig?tab=readme-ov-file#table-of-contents).
836+
//!
837+
//! Full examples are available in the [examples](https://github.com/rcalixte/libqt6zig-examples) repository.
838+
//!
839+
//! There is also a [demo application](https://github.com/rcalixte/libqt6zig-demo) that demonstrates the use of the library
840+
//! with a simpler build system than the examples, while also demonstrating a
841+
//! more realistic use of the library for a single application. The demo also
842+
//! includes exercises designed to help developers onboard to the library.
843+
`
844+
zigDefs := "\n// THIS FILE IS AUTOMATICALLY GENERATED\n\npub const C = @import(\"qtzig\");\n\n"
845+
zigDefs = zigDocs + zigDefs + strings.Join(zigIncList, "\n")
816846
zigQtPath := filepath.Join(outDir, "src", "libqt6.zig")
817847
err = os.WriteFile(zigQtPath, []byte(zigDefs), 0644)
818848
if err != nil {

cmd/genbindings/emitzig.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ const qtc = @import("qt6c");%%_IMPORTLIBS_%% %%_STRUCTDEFS_%%
16921692
if subjectURL != "" {
16931693
maybeCharts := ifv(strings.Contains(src.Filename, "QtCharts") && inheritedFrom == "" && subjectURL != "qobject", "-qtcharts", "")
16941694
pageURL := getPageUrl(QtPage, subjectURL+maybeCharts, cmdURL, className)
1695-
docCommentUrl = "\n/// [Qt documentation](" + pageURL + ")\n///\n"
1695+
docCommentUrl = "\n/// [Upstream resources](" + pageURL + ")\n///\n"
16961696
ret.WriteString(docCommentUrl)
16971697
}
16981698

@@ -1908,7 +1908,7 @@ const qtc = @import("qt6c");%%_IMPORTLIBS_%% %%_STRUCTDEFS_%%
19081908
}
19091909
maybeCharts := ifv(strings.Contains(src.Filename, "QtCharts") && inheritedFrom == "", "-qtcharts", "")
19101910
pageURL := getPageUrl(QtPage, subjectURL+maybeCharts, cmdURL, className)
1911-
documentationURL := "\n/// [Qt documentation](" + pageURL + ")\n///\n"
1911+
documentationURL := "\n/// [Upstream resources](" + pageURL + ")\n///\n"
19121912

19131913
// Add a package-private function to call the C++ base class method
19141914
// QWidget_PaintEvent
@@ -2015,7 +2015,7 @@ const qtc = @import("qt6c");%%_IMPORTLIBS_%% %%_STRUCTDEFS_%%
20152015
if subjectURL != "" {
20162016
maybeCharts := ifv(strings.Contains(src.Filename, "QtCharts") && inheritedFrom == "" && subjectURL != "qobject", "-qtcharts", "")
20172017
pageURL := getPageUrl(QtPage, subjectURL+maybeCharts, cmdURL, className)
2018-
docCommentUrl = "\n/// [Qt documentation](" + pageURL + ")\n///\n"
2018+
docCommentUrl = "\n/// [Upstream resources](" + pageURL + ")\n///\n"
20192019
}
20202020

20212021
slotComma := ifv(len(m.Parameters) != 0, ", ", "")
@@ -2036,7 +2036,7 @@ const qtc = @import("qt6c");%%_IMPORTLIBS_%% %%_STRUCTDEFS_%%
20362036
(strings.Contains(src.Filename, "signon-qt") && zigStructName[0] != 'Q')
20372037

20382038
pageUrl := getPageUrl(DtorPage, ifv(isSpecialCase, zigStructName, getPageName(zigStructName))+maybeCharts, "", zigStructName)
2039-
ret.WriteString(ifv(pageUrl != "", "\n/// [Qt documentation]("+pageUrl+")\n///\n", "\n") +
2039+
ret.WriteString(ifv(pageUrl != "", "\n/// [Upstream resources]("+pageUrl+")\n///\n", "\n") +
20402040
" /// Delete this object from C++ memory.\n///\n" +
20412041
" /// ``` self: QtC." + zigStructName + " ```\n" +
20422042
" pub fn QDelete(self: ?*anyopaque) void {\n" +

0 commit comments

Comments
 (0)