swiftdoc 0.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. swiftdoc-0.6.1/.gitattributes +3 -0
  2. swiftdoc-0.6.1/.github/ISSUE_TEMPLATE/bug_report.yml +83 -0
  3. swiftdoc-0.6.1/.github/ISSUE_TEMPLATE/config.yml +5 -0
  4. swiftdoc-0.6.1/.github/ISSUE_TEMPLATE/feature_request.yml +47 -0
  5. swiftdoc-0.6.1/.github/pull_request_template.md +23 -0
  6. swiftdoc-0.6.1/.github/workflows/action-test.yaml +138 -0
  7. swiftdoc-0.6.1/.github/workflows/ci.yaml +78 -0
  8. swiftdoc-0.6.1/.github/workflows/packaging.yaml +53 -0
  9. swiftdoc-0.6.1/.github/workflows/release.yaml +265 -0
  10. swiftdoc-0.6.1/.gitignore +4 -0
  11. swiftdoc-0.6.1/.pre-commit-hooks.yaml +13 -0
  12. swiftdoc-0.6.1/CHANGELOG.md +73 -0
  13. swiftdoc-0.6.1/Cargo.lock +1923 -0
  14. swiftdoc-0.6.1/Cargo.toml +57 -0
  15. swiftdoc-0.6.1/LICENSE +21 -0
  16. swiftdoc-0.6.1/PKG-INFO +898 -0
  17. swiftdoc-0.6.1/README.md +872 -0
  18. swiftdoc-0.6.1/action.yml +90 -0
  19. swiftdoc-0.6.1/assets/app.js +670 -0
  20. swiftdoc-0.6.1/assets/base.html +46 -0
  21. swiftdoc-0.6.1/assets/document.html +24 -0
  22. swiftdoc-0.6.1/assets/index.html +123 -0
  23. swiftdoc-0.6.1/assets/module.html +227 -0
  24. swiftdoc-0.6.1/assets/sidebar.html +60 -0
  25. swiftdoc-0.6.1/assets/style.css +1290 -0
  26. swiftdoc-0.6.1/assets/theme-README.md +58 -0
  27. swiftdoc-0.6.1/benchmarks/bench.py +188 -0
  28. swiftdoc-0.6.1/benchmarks/benchmark.svg +74 -0
  29. swiftdoc-0.6.1/benchmarks/make_chart.py +120 -0
  30. swiftdoc-0.6.1/benchmarks/results.json +38 -0
  31. swiftdoc-0.6.1/docs/api.schema.json +182 -0
  32. swiftdoc-0.6.1/docs/ci.md +40 -0
  33. swiftdoc-0.6.1/docs/github-pages.md +53 -0
  34. swiftdoc-0.6.1/docs/migrating.md +42 -0
  35. swiftdoc-0.6.1/docs/templates.md +184 -0
  36. swiftdoc-0.6.1/pyproject.toml +41 -0
  37. swiftdoc-0.6.1/scripts/action/install.sh +157 -0
  38. swiftdoc-0.6.1/scripts/action/run.sh +40 -0
  39. swiftdoc-0.6.1/scripts/build.ps1 +45 -0
  40. swiftdoc-0.6.1/scripts/build.sh +59 -0
  41. swiftdoc-0.6.1/scripts/install.ps1 +62 -0
  42. swiftdoc-0.6.1/scripts/install.sh +84 -0
  43. swiftdoc-0.6.1/scripts/pre-commit.sh +43 -0
  44. swiftdoc-0.6.1/scripts/wheel-smoke-test.sh +22 -0
  45. swiftdoc-0.6.1/src/annotations.rs +382 -0
  46. swiftdoc-0.6.1/src/cache.rs +440 -0
  47. swiftdoc-0.6.1/src/config.rs +810 -0
  48. swiftdoc-0.6.1/src/coverage.rs +523 -0
  49. swiftdoc-0.6.1/src/docstring.rs +1511 -0
  50. swiftdoc-0.6.1/src/generator.rs +2431 -0
  51. swiftdoc-0.6.1/src/highlight.rs +182 -0
  52. swiftdoc-0.6.1/src/intersphinx.rs +234 -0
  53. swiftdoc-0.6.1/src/inventory.rs +111 -0
  54. swiftdoc-0.6.1/src/main.rs +742 -0
  55. swiftdoc-0.6.1/src/models.rs +248 -0
  56. swiftdoc-0.6.1/src/output/json.rs +351 -0
  57. swiftdoc-0.6.1/src/output/markdown.rs +616 -0
  58. swiftdoc-0.6.1/src/output/mod.rs +4 -0
  59. swiftdoc-0.6.1/src/pages.rs +200 -0
  60. swiftdoc-0.6.1/src/parser.rs +1486 -0
  61. swiftdoc-0.6.1/src/resolver.rs +224 -0
  62. swiftdoc-0.6.1/src/serve.rs +500 -0
  63. swiftdoc-0.6.1/src/tui.rs +945 -0
  64. swiftdoc-0.6.1/src/versions.rs +149 -0
  65. swiftdoc-0.6.1/tests/a11y/audit.js +115 -0
  66. swiftdoc-0.6.1/tests/a11y/keyboard.js +174 -0
  67. swiftdoc-0.6.1/tests/a11y/package-lock.json +53 -0
  68. swiftdoc-0.6.1/tests/a11y/package.json +13 -0
  69. swiftdoc-0.6.1/tests/a11y/structure.js +58 -0
  70. swiftdoc-0.6.1/tests/annotations.rs +234 -0
  71. swiftdoc-0.6.1/tests/api_json.rs +663 -0
  72. swiftdoc-0.6.1/tests/config.rs +200 -0
  73. swiftdoc-0.6.1/tests/coverage.rs +273 -0
  74. swiftdoc-0.6.1/tests/docstrings.rs +272 -0
  75. swiftdoc-0.6.1/tests/fixtures/annotations/__init__.py +1 -0
  76. swiftdoc-0.6.1/tests/fixtures/annotations/console.py +60 -0
  77. swiftdoc-0.6.1/tests/fixtures/annotations/json.py +5 -0
  78. swiftdoc-0.6.1/tests/fixtures/annotations/style.py +15 -0
  79. swiftdoc-0.6.1/tests/fixtures/annotations/widgets/__init__.py +1 -0
  80. swiftdoc-0.6.1/tests/fixtures/annotations/widgets/button.py +12 -0
  81. swiftdoc-0.6.1/tests/fixtures/broken/bad.py +1 -0
  82. swiftdoc-0.6.1/tests/fixtures/broken/links.py +5 -0
  83. swiftdoc-0.6.1/tests/fixtures/coverage/__init__.py +1 -0
  84. swiftdoc-0.6.1/tests/fixtures/coverage/_internal.py +2 -0
  85. swiftdoc-0.6.1/tests/fixtures/coverage/api.py +24 -0
  86. swiftdoc-0.6.1/tests/fixtures/coverage/guide.py +5 -0
  87. swiftdoc-0.6.1/tests/fixtures/coverage/plain.py +6 -0
  88. swiftdoc-0.6.1/tests/fixtures/docstrings/google.py +63 -0
  89. swiftdoc-0.6.1/tests/fixtures/docstrings/numpy_style.py +50 -0
  90. swiftdoc-0.6.1/tests/fixtures/docstrings/odd.py +43 -0
  91. swiftdoc-0.6.1/tests/fixtures/docstrings/rest_style.py +18 -0
  92. swiftdoc-0.6.1/tests/fixtures/intersphinx/pkg/paths.py +15 -0
  93. swiftdoc-0.6.1/tests/fixtures/macros/alpha.py +6 -0
  94. swiftdoc-0.6.1/tests/fixtures/macros/handbook.py +32 -0
  95. swiftdoc-0.6.1/tests/fixtures/macros/img/pic.png +0 -0
  96. swiftdoc-0.6.1/tests/fixtures/macros/pkg/__init__.py +1 -0
  97. swiftdoc-0.6.1/tests/fixtures/macros/pkg/deep.py +8 -0
  98. swiftdoc-0.6.1/tests/fixtures/macros/pkg/problems.py +15 -0
  99. swiftdoc-0.6.1/tests/fixtures/macros/zeta.py +18 -0
  100. swiftdoc-0.6.1/tests/fixtures/nested/compat.py +112 -0
  101. swiftdoc-0.6.1/tests/fixtures/pages/docs/01_install.md +5 -0
  102. swiftdoc-0.6.1/tests/fixtures/pages/docs/02_guide.md +8 -0
  103. swiftdoc-0.6.1/tests/fixtures/pages/docs/advanced/tuning.md +6 -0
  104. swiftdoc-0.6.1/tests/fixtures/pages/docs/index.md +3 -0
  105. swiftdoc-0.6.1/tests/fixtures/pages/pkg/__init__.py +1 -0
  106. swiftdoc-0.6.1/tests/fixtures/pages/pkg/engine.py +5 -0
  107. swiftdoc-0.6.1/tests/fixtures/sample/01_core/__init__.py +8 -0
  108. swiftdoc-0.6.1/tests/fixtures/sample/01_core/engine.py +42 -0
  109. swiftdoc-0.6.1/tests/fixtures/sample/01_core/sub/__init__.py +0 -0
  110. swiftdoc-0.6.1/tests/fixtures/sample/01_core/sub/engine.py +6 -0
  111. swiftdoc-0.6.1/tests/fixtures/sample/__init__.py +1 -0
  112. swiftdoc-0.6.1/tests/fixtures/sample/guide.py +20 -0
  113. swiftdoc-0.6.1/tests/fixtures/sample/img/logo.png +0 -0
  114. swiftdoc-0.6.1/tests/fixtures/sample/utils/helpers.py +7 -0
  115. swiftdoc-0.6.1/tests/fixtures/sample/venv/lib/inside_venv.py +1 -0
  116. swiftdoc-0.6.1/tests/fixtures/templates/base-footer/base.html +3 -0
  117. swiftdoc-0.6.1/tests/fixtures/templates/blocks/module.html +7 -0
  118. swiftdoc-0.6.1/tests/fixtures/templates/blocks/partials/footer.html +1 -0
  119. swiftdoc-0.6.1/tests/fixtures/templates/legacy/document.html +51 -0
  120. swiftdoc-0.6.1/tests/fixtures/templates/legacy/index.html +138 -0
  121. swiftdoc-0.6.1/tests/fixtures/templates/legacy/module.html +128 -0
  122. swiftdoc-0.6.1/tests/fixtures/variables/config.py +71 -0
  123. swiftdoc-0.6.1/tests/fixtures/variables/links.py +8 -0
  124. swiftdoc-0.6.1/tests/fixtures/visibility/__init__.py +1 -0
  125. swiftdoc-0.6.1/tests/fixtures/visibility/_helpers.py +5 -0
  126. swiftdoc-0.6.1/tests/fixtures/visibility/_internal/__init__.py +5 -0
  127. swiftdoc-0.6.1/tests/fixtures/visibility/_internal/core.py +5 -0
  128. swiftdoc-0.6.1/tests/fixtures/visibility/api.py +51 -0
  129. swiftdoc-0.6.1/tests/fixtures/visibility/plain.py +23 -0
  130. swiftdoc-0.6.1/tests/fixtures/visibility/shapes/__init__.py +1 -0
  131. swiftdoc-0.6.1/tests/fixtures/visibility/shapes/circle.py +5 -0
  132. swiftdoc-0.6.1/tests/golden/visibility-include-private/nav-data.js +1 -0
  133. swiftdoc-0.6.1/tests/golden/visibility-include-private/search-index.js +1 -0
  134. swiftdoc-0.6.1/tests/incremental.rs +670 -0
  135. swiftdoc-0.6.1/tests/intersphinx.rs +92 -0
  136. swiftdoc-0.6.1/tests/inventory.rs +59 -0
  137. swiftdoc-0.6.1/tests/macros.rs +297 -0
  138. swiftdoc-0.6.1/tests/markdown.rs +567 -0
  139. swiftdoc-0.6.1/tests/nested.rs +245 -0
  140. swiftdoc-0.6.1/tests/pages.rs +112 -0
  141. swiftdoc-0.6.1/tests/serve.rs +275 -0
  142. swiftdoc-0.6.1/tests/site.rs +776 -0
  143. swiftdoc-0.6.1/tests/snapshots/markdown-sample/01_core/engine.md +93 -0
  144. swiftdoc-0.6.1/tests/snapshots/markdown-sample/01_core/index.md +18 -0
  145. swiftdoc-0.6.1/tests/snapshots/markdown-sample/01_core/sub/engine.md +16 -0
  146. swiftdoc-0.6.1/tests/snapshots/markdown-sample/01_core/sub/index.md +2 -0
  147. swiftdoc-0.6.1/tests/snapshots/markdown-sample/__init__.md +4 -0
  148. swiftdoc-0.6.1/tests/snapshots/markdown-sample/guide.md +23 -0
  149. swiftdoc-0.6.1/tests/snapshots/markdown-sample/index.md +15 -0
  150. swiftdoc-0.6.1/tests/snapshots/markdown-sample/llms-full.txt +217 -0
  151. swiftdoc-0.6.1/tests/snapshots/markdown-sample/llms.txt +15 -0
  152. swiftdoc-0.6.1/tests/snapshots/markdown-sample/utils/helpers.md +22 -0
  153. swiftdoc-0.6.1/tests/snapshots/sample/01_core/engine.html +1 -0
  154. swiftdoc-0.6.1/tests/snapshots/sample/01_core/index.html +1 -0
  155. swiftdoc-0.6.1/tests/snapshots/sample/01_core/sub/engine.html +1 -0
  156. swiftdoc-0.6.1/tests/snapshots/sample/01_core/sub/index.html +1 -0
  157. swiftdoc-0.6.1/tests/snapshots/sample/__init__.html +1 -0
  158. swiftdoc-0.6.1/tests/snapshots/sample/guide.html +1 -0
  159. swiftdoc-0.6.1/tests/snapshots/sample/index.html +1 -0
  160. swiftdoc-0.6.1/tests/snapshots/sample/utils/helpers.html +1 -0
  161. swiftdoc-0.6.1/tests/snapshots/sample-markdown/01_core/engine.html +1 -0
  162. swiftdoc-0.6.1/tests/theme.rs +280 -0
  163. swiftdoc-0.6.1/tests/variables.rs +212 -0
  164. swiftdoc-0.6.1/tests/versions.rs +100 -0
  165. swiftdoc-0.6.1/tests/visibility.rs +266 -0
@@ -0,0 +1,3 @@
1
+ # Shell scripts must keep LF endings, even in a Windows checkout
2
+ # (core.autocrlf), or sh/bash fail on the carriage returns.
3
+ *.sh text eol=lf
@@ -0,0 +1,83 @@
1
+ name: Bug report
2
+ description: Something is wrong with swiftdoc or the site it generates.
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for reporting. The smallest Python file that shows the problem is the most useful thing you can include.
9
+
10
+ - type: textarea
11
+ id: what-happened
12
+ attributes:
13
+ label: What happened
14
+ description: What did you see, and what did you expect instead?
15
+ placeholder: |
16
+ The method `Engine.run` is missing from the generated page.
17
+ I expected it to be listed under the `Engine` class.
18
+ validations:
19
+ required: true
20
+
21
+ - type: textarea
22
+ id: reproduce
23
+ attributes:
24
+ label: How to reproduce
25
+ description: The command you ran and a minimal Python file (or a public repository) that triggers the problem.
26
+ placeholder: |
27
+ swiftdoc --src ./src --out ./docs --name myproject
28
+
29
+ ```python
30
+ class Engine:
31
+ def run(self) -> None:
32
+ """Start the engine."""
33
+ ```
34
+ validations:
35
+ required: true
36
+
37
+ - type: dropdown
38
+ id: area
39
+ attributes:
40
+ label: Where is the problem?
41
+ options:
42
+ - Parsing (missing or wrong classes, functions, signatures)
43
+ - Docstring rendering (Markdown, macros, code highlighting)
44
+ - Generated site (layout, theme, search, navigation)
45
+ - Command line, configuration or setup wizard
46
+ - Installation or release binaries
47
+ - Something else
48
+ validations:
49
+ required: true
50
+
51
+ - type: input
52
+ id: version
53
+ attributes:
54
+ label: swiftdoc version
55
+ description: Output of `swiftdoc --version`.
56
+ placeholder: swiftdoc 0.6.1
57
+ validations:
58
+ required: true
59
+
60
+ - type: dropdown
61
+ id: os
62
+ attributes:
63
+ label: Operating system
64
+ options:
65
+ - Linux
66
+ - macOS
67
+ - Windows
68
+ validations:
69
+ required: true
70
+
71
+ - type: input
72
+ id: browser
73
+ attributes:
74
+ label: Browser
75
+ description: Only for problems with the generated site.
76
+ placeholder: Firefox 140, Safari 19, ...
77
+
78
+ - type: textarea
79
+ id: output
80
+ attributes:
81
+ label: Terminal output
82
+ description: Any errors or warnings swiftdoc printed. This is shown as code, so no backticks are needed.
83
+ render: text
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: true
2
+ contact_links:
3
+ - name: Usage and options
4
+ url: https://github.com/kura120/swiftdoc#usage
5
+ about: Flags, macros, custom templates and troubleshooting are covered in the README.
@@ -0,0 +1,47 @@
1
+ name: Feature request
2
+ description: Suggest a new feature or an improvement.
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Please check the [open issues](https://github.com/kura120/swiftdoc/issues) and the [roadmap](https://github.com/kura120/swiftdoc/issues/3) first, in case it is already planned.
9
+
10
+ - type: textarea
11
+ id: problem
12
+ attributes:
13
+ label: Problem
14
+ description: What are you trying to do, and what gets in the way today?
15
+ placeholder: My project uses Google-style docstrings, and `Args:` sections show up as plain text.
16
+ validations:
17
+ required: true
18
+
19
+ - type: textarea
20
+ id: proposal
21
+ attributes:
22
+ label: Proposal
23
+ description: What should swiftdoc do? Example input and output help a lot.
24
+ validations:
25
+ required: true
26
+
27
+ - type: dropdown
28
+ id: area
29
+ attributes:
30
+ label: Area
31
+ options:
32
+ - Parsing and docstrings
33
+ - Templates and theme
34
+ - Command line and configuration
35
+ - Output formats
36
+ - Performance
37
+ - Installation and CI integration
38
+ - Documentation
39
+ - Something else
40
+ validations:
41
+ required: true
42
+
43
+ - type: textarea
44
+ id: alternatives
45
+ attributes:
46
+ label: Alternatives
47
+ description: Workarounds you use today, or how other tools (pdoc, Sphinx, ...) handle this.
@@ -0,0 +1,23 @@
1
+ ## Summary
2
+
3
+ <!-- What does this change, and why? -->
4
+
5
+ Closes #
6
+
7
+ ## Changes
8
+
9
+ -
10
+
11
+ ## Test plan
12
+
13
+ - [ ] `cargo fmt --check`
14
+ - [ ] `cargo clippy --locked --all-targets -- -D warnings`
15
+ - [ ] `cargo test`
16
+ - [ ] Generated a site for a real project and checked the result
17
+ - [ ] Parser or renderer change: release-build timing on a large package compared with `master`
18
+ - [ ] Theme change: checked light and dark, and phone and desktop widths (screenshots below)
19
+ - [ ] README updated for new flags, configuration or macros
20
+
21
+ ## Screenshots
22
+
23
+ <!-- For theme or layout changes. Delete otherwise. -->
@@ -0,0 +1,138 @@
1
+ name: Action self-test
2
+
3
+ # Exercises action.yml on each runner OS. "release" downloads the latest
4
+ # published binary (the download, checksum and extract path); "source" builds
5
+ # this commit with cargo, so changes to swiftdoc itself are covered too.
6
+
7
+ on:
8
+ push:
9
+ branches: [master]
10
+ paths:
11
+ - action.yml
12
+ - scripts/action/**
13
+ - scripts/pre-commit.sh
14
+ - .pre-commit-hooks.yaml
15
+ - .github/workflows/action-test.yaml
16
+ pull_request:
17
+ paths:
18
+ - action.yml
19
+ - scripts/action/**
20
+ - scripts/pre-commit.sh
21
+ - .pre-commit-hooks.yaml
22
+ - .github/workflows/action-test.yaml
23
+ workflow_dispatch:
24
+
25
+ permissions:
26
+ contents: read
27
+
28
+ jobs:
29
+ action:
30
+ name: Action (${{ matrix.os }}, ${{ matrix.install }})
31
+ runs-on: ${{ matrix.os }}
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ os: [ubuntu-latest, macos-latest, windows-latest]
36
+ # "release" joins once v0.6.1, the first complete swiftdoc release, is published.
37
+ install: [source]
38
+ include:
39
+ - os: ubuntu-24.04-arm
40
+ install: source
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+
44
+ - name: Install Rust toolchain
45
+ if: matrix.install == 'source'
46
+ uses: dtolnay/rust-toolchain@stable
47
+
48
+ - name: Run the action
49
+ id: swiftdoc
50
+ uses: ./
51
+ with:
52
+ install: ${{ matrix.install }}
53
+ src: tests/fixtures/sample
54
+ out: _site-test
55
+ name: sample
56
+ args: --strict --theme dark --doc-version "1.2.3 beta"
57
+
58
+ - name: Check the output
59
+ shell: bash
60
+ env:
61
+ OUT: ${{ steps.swiftdoc.outputs.out }}
62
+ VERSION: ${{ steps.swiftdoc.outputs.version }}
63
+ run: |
64
+ set -x
65
+ test "$OUT" = "_site-test"
66
+ test -n "$VERSION"
67
+ test -f _site-test/index.html
68
+ test -f _site-test/guide.html
69
+ test -f _site-test/search-index.js
70
+ grep -q "1.2.3 beta" _site-test/index.html
71
+
72
+ pinned:
73
+ # Runs once v0.6.1, the first complete swiftdoc release, is published.
74
+ if: false
75
+ name: Action (ubuntu-latest, pinned version)
76
+ runs-on: ubuntu-latest
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+
80
+ - name: Run the action
81
+ id: swiftdoc
82
+ uses: ./
83
+ with:
84
+ version: "0.6.1"
85
+ src: tests/fixtures/sample
86
+ out: _site-test
87
+ name: sample
88
+
89
+ - name: Check the output
90
+ shell: bash
91
+ env:
92
+ VERSION: ${{ steps.swiftdoc.outputs.version }}
93
+ run: |
94
+ set -x
95
+ test "$VERSION" = "0.6.1"
96
+ test -f _site-test/index.html
97
+
98
+ pre-commit:
99
+ name: pre-commit hook
100
+ runs-on: ubuntu-latest
101
+ steps:
102
+ - uses: actions/checkout@v4
103
+
104
+ # Builds from source until v0.6.1, the first complete swiftdoc release, is published.
105
+ - uses: dtolnay/rust-toolchain@stable
106
+
107
+ - name: Install swiftdoc
108
+ uses: ./
109
+ with:
110
+ install: source
111
+ src: tests/fixtures/sample
112
+ out: _site-test
113
+
114
+ - uses: actions/setup-python@v5
115
+ with:
116
+ python-version: "3.x"
117
+
118
+ - name: Try the hook against a scratch repository
119
+ shell: bash
120
+ run: |
121
+ set -x
122
+ pip install pre-commit
123
+ hook_repo="$PWD"
124
+ work="$RUNNER_TEMP/consumer"
125
+ mkdir -p "$work/pkg"
126
+ cd "$work"
127
+ git init -q .
128
+ printf '"""Package.\n\n#sd-doc-link: pkg.engine.Engine\n"""\n' > pkg/__init__.py
129
+ printf '"""Engine module."""\n\n\nclass Engine:\n """Runs things."""\n' > pkg/engine.py
130
+ git add -A
131
+ pre-commit try-repo "$hook_repo" swiftdoc --all-files
132
+ # A broken doc-link must fail the hook.
133
+ sed -i 's/pkg.engine.Engine/pkg.engine.Missing/' pkg/__init__.py
134
+ git add -A
135
+ if pre-commit try-repo "$hook_repo" swiftdoc --all-files; then
136
+ echo "hook passed on a broken doc-link"
137
+ exit 1
138
+ fi
@@ -0,0 +1,78 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ env:
12
+ CARGO_TERM_COLOR: always
13
+
14
+ jobs:
15
+ lint:
16
+ name: Format and Clippy
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: dtolnay/rust-toolchain@stable
21
+ with:
22
+ components: rustfmt, clippy
23
+ - uses: Swatinem/rust-cache@v2
24
+ - name: Check formatting
25
+ run: cargo fmt --check
26
+ - name: Clippy
27
+ run: cargo clippy --locked --all-targets -- -D warnings
28
+
29
+ test:
30
+ name: Test (${{ matrix.os }})
31
+ runs-on: ${{ matrix.os }}
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ os: [ubuntu-latest, macos-latest, windows-latest]
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: dtolnay/rust-toolchain@stable
39
+ - uses: Swatinem/rust-cache@v2
40
+ - name: Build
41
+ run: cargo build --locked
42
+ - name: Test
43
+ run: cargo test --locked
44
+
45
+ a11y:
46
+ name: Accessibility (axe-core, keyboard)
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ - uses: dtolnay/rust-toolchain@stable
51
+ - uses: Swatinem/rust-cache@v2
52
+ - uses: actions/setup-node@v4
53
+ with:
54
+ node-version: 22
55
+ cache: npm
56
+ cache-dependency-path: tests/a11y/package-lock.json
57
+ - name: Generate the fixture sites
58
+ # An empty --config keeps the repository's own pyproject.toml out.
59
+ run: |
60
+ cargo build --locked
61
+ ./target/debug/swiftdoc --config /dev/null --src tests/fixtures/sample --out "$RUNNER_TEMP/sample-site" --name demo
62
+ ./target/debug/swiftdoc --config /dev/null --src tests/fixtures/variables --out "$RUNNER_TEMP/variables-site" --name variables
63
+ ./target/debug/swiftdoc --config /dev/null --src tests/fixtures/nested --out "$RUNNER_TEMP/nested-site" --name nested
64
+ ./target/debug/swiftdoc --config /dev/null --src tests/fixtures/docstrings --out "$RUNNER_TEMP/docstrings-site" --name docstrings
65
+ - name: Install axe-core and Playwright
66
+ working-directory: tests/a11y
67
+ run: |
68
+ npm ci
69
+ npx playwright install --with-deps chromium
70
+ - name: axe-core, WCAG 2.2 AA (3 layouts x light and dark)
71
+ working-directory: tests/a11y
72
+ run: node audit.js "$RUNNER_TEMP/sample-site" "$RUNNER_TEMP/variables-site" "$RUNNER_TEMP/nested-site" "$RUNNER_TEMP/docstrings-site" --quick
73
+ - name: Keyboard
74
+ working-directory: tests/a11y
75
+ run: node keyboard.js "$RUNNER_TEMP/sample-site"
76
+ - name: Landmarks and headings
77
+ working-directory: tests/a11y
78
+ run: node structure.js "$RUNNER_TEMP/sample-site" "$RUNNER_TEMP/variables-site" "$RUNNER_TEMP/nested-site" "$RUNNER_TEMP/docstrings-site"
@@ -0,0 +1,53 @@
1
+ name: Packaging
2
+
3
+ # Builds the swiftdoc wheel and sdist the way release.yaml does, installs the
4
+ # wheel and runs it, so packaging changes are tested before a release.
5
+
6
+ on:
7
+ pull_request:
8
+ paths:
9
+ - pyproject.toml
10
+ - Cargo.toml
11
+ - Cargo.lock
12
+ - README.md
13
+ - scripts/wheel-smoke-test.sh
14
+ - .github/workflows/packaging.yaml
15
+ - .github/workflows/release.yaml
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ wheel:
23
+ name: Build and test wheel (ubuntu)
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+
28
+ - name: Build wheel
29
+ uses: PyO3/maturin-action@v1
30
+ with:
31
+ target: x86_64-unknown-linux-gnu
32
+ manylinux: auto
33
+ args: --release --locked --out dist
34
+
35
+ - name: Build sdist
36
+ uses: PyO3/maturin-action@v1
37
+ with:
38
+ command: sdist
39
+ args: --out dist
40
+
41
+ - uses: actions/setup-python@v5
42
+ with:
43
+ python-version: "3.x"
44
+
45
+ - name: Check metadata
46
+ run: |
47
+ python -m pip install twine
48
+ python -m twine check --strict dist/*
49
+
50
+ - name: Install the wheel and run it
51
+ run: |
52
+ python -m pip install --no-index --find-links dist swiftdoc
53
+ sh scripts/wheel-smoke-test.sh
@@ -0,0 +1,265 @@
1
+ name: Release Binaries
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ publish:
13
+ name: Build and Upload (${{ matrix.target }})
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ include:
19
+ - os: ubuntu-latest
20
+ target: x86_64-unknown-linux-gnu
21
+ artifact_name: swiftdoc
22
+ asset_name: swiftdoc-x86_64-unknown-linux-gnu.tar.gz
23
+ - os: ubuntu-24.04-arm
24
+ target: aarch64-unknown-linux-gnu
25
+ artifact_name: swiftdoc
26
+ asset_name: swiftdoc-aarch64-unknown-linux-gnu.tar.gz
27
+ - os: macos-latest
28
+ target: x86_64-apple-darwin
29
+ artifact_name: swiftdoc
30
+ asset_name: swiftdoc-x86_64-apple-darwin.tar.gz
31
+ - os: macos-latest
32
+ target: aarch64-apple-darwin
33
+ artifact_name: swiftdoc
34
+ asset_name: swiftdoc-aarch64-apple-darwin.tar.gz
35
+ - os: windows-latest
36
+ target: x86_64-pc-windows-msvc
37
+ artifact_name: swiftdoc.exe
38
+ asset_name: swiftdoc-x86_64-pc-windows-msvc.zip
39
+
40
+ steps:
41
+ - name: Checkout Source Code
42
+ uses: actions/checkout@v4
43
+
44
+ - name: Install Rust Toolchain
45
+ uses: dtolnay/rust-toolchain@stable
46
+ with:
47
+ targets: ${{ matrix.target }}
48
+
49
+ - name: Check tag matches Cargo.toml version
50
+ shell: bash
51
+ run: |
52
+ version=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
53
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
54
+ echo "Tag $GITHUB_REF_NAME does not match Cargo.toml version $version"
55
+ exit 1
56
+ fi
57
+
58
+ # Release binaries are not UPX-packed: the archives are already
59
+ # compressed, and packed executables are unsupported on macOS and
60
+ # frequently flagged by antivirus tools on Windows.
61
+ - name: Build Binary (Unix)
62
+ if: matrix.os != 'windows-latest'
63
+ run: |
64
+ chmod +x ./scripts/build.sh
65
+ ./scripts/build.sh ${{ matrix.target }}
66
+
67
+ - name: Build Binary (Windows)
68
+ if: matrix.os == 'windows-latest'
69
+ run: pwsh -File ./scripts/build.ps1 -Target ${{ matrix.target }}
70
+
71
+ - name: Archive Binary (Unix)
72
+ if: matrix.os != 'windows-latest'
73
+ run: |
74
+ tar -czf ${{ matrix.asset_name }} -C target/${{ matrix.target }}/release ${{ matrix.artifact_name }}
75
+
76
+ - name: Archive Binary (Windows)
77
+ if: matrix.os == 'windows-latest'
78
+ shell: pwsh
79
+ run: |
80
+ Compress-Archive -Path target\${{ matrix.target }}\release\${{ matrix.artifact_name }} -DestinationPath ${{ matrix.asset_name }}
81
+
82
+ # "<hash> <file>", the format sha256sum/shasum -c and the installers read.
83
+ - name: Write SHA-256 checksum
84
+ shell: bash
85
+ run: |
86
+ if command -v sha256sum >/dev/null 2>&1; then
87
+ sha256sum ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256
88
+ else
89
+ shasum -a 256 ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256
90
+ fi
91
+ cat ${{ matrix.asset_name }}.sha256
92
+
93
+ - name: Create and Upload to GitHub Release
94
+ uses: softprops/action-gh-release@v2
95
+ with:
96
+ files: |
97
+ ${{ matrix.asset_name }}
98
+ ${{ matrix.asset_name }}.sha256
99
+ env:
100
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101
+
102
+ # Python wheels for PyPI, published as `swiftdoc`. Each wheel holds only the
103
+ # swiftdoc binary (maturin `bindings = "bin"`, see pyproject.toml), which pip
104
+ # installs as the `swiftdoc` command. Linux wheels are built in the manylinux
105
+ # and musllinux containers maturin-action provides.
106
+ wheels:
107
+ name: Wheel (${{ matrix.platform }})
108
+ runs-on: ${{ matrix.os }}
109
+ permissions:
110
+ contents: read
111
+ strategy:
112
+ fail-fast: false
113
+ matrix:
114
+ include:
115
+ - os: ubuntu-latest
116
+ platform: manylinux-x86_64
117
+ target: x86_64-unknown-linux-gnu
118
+ manylinux: auto
119
+ - os: ubuntu-latest
120
+ platform: manylinux-aarch64
121
+ target: aarch64-unknown-linux-gnu
122
+ manylinux: auto
123
+ - os: ubuntu-latest
124
+ platform: musllinux-x86_64
125
+ target: x86_64-unknown-linux-musl
126
+ manylinux: musllinux_1_2
127
+ - os: ubuntu-latest
128
+ platform: musllinux-aarch64
129
+ target: aarch64-unknown-linux-musl
130
+ manylinux: musllinux_1_2
131
+ - os: macos-latest
132
+ platform: macos-x86_64
133
+ target: x86_64-apple-darwin
134
+ - os: macos-latest
135
+ platform: macos-aarch64
136
+ target: aarch64-apple-darwin
137
+ - os: windows-latest
138
+ platform: windows-x86_64
139
+ target: x86_64-pc-windows-msvc
140
+ steps:
141
+ - uses: actions/checkout@v4
142
+
143
+ - name: Build wheel
144
+ uses: PyO3/maturin-action@v1
145
+ with:
146
+ target: ${{ matrix.target }}
147
+ manylinux: ${{ matrix.manylinux }}
148
+ args: --release --locked --out dist
149
+
150
+ - uses: actions/upload-artifact@v4
151
+ with:
152
+ name: wheels-${{ matrix.platform }}
153
+ path: dist
154
+
155
+ sdist:
156
+ name: Source distribution
157
+ runs-on: ubuntu-latest
158
+ permissions:
159
+ contents: read
160
+ steps:
161
+ - uses: actions/checkout@v4
162
+
163
+ - name: Build sdist
164
+ uses: PyO3/maturin-action@v1
165
+ with:
166
+ command: sdist
167
+ args: --out dist
168
+
169
+ - uses: actions/upload-artifact@v4
170
+ with:
171
+ name: wheels-sdist
172
+ path: dist
173
+
174
+ # Installs every wheel, and the sdist, on a machine it is meant for and runs
175
+ # it, so a broken wheel never reaches PyPI.
176
+ wheel-test:
177
+ name: Test wheel (${{ matrix.platform }})
178
+ needs: [wheels, sdist]
179
+ runs-on: ${{ matrix.os }}
180
+ permissions:
181
+ contents: read
182
+ strategy:
183
+ fail-fast: false
184
+ matrix:
185
+ include:
186
+ - os: ubuntu-latest
187
+ platform: manylinux-x86_64
188
+ - os: ubuntu-24.04-arm
189
+ platform: manylinux-aarch64
190
+ - os: ubuntu-latest
191
+ platform: musllinux-x86_64
192
+ container: python:3.13-alpine
193
+ - os: ubuntu-24.04-arm
194
+ platform: musllinux-aarch64
195
+ container: python:3.13-alpine
196
+ - os: macos-15-intel
197
+ platform: macos-x86_64
198
+ - os: macos-latest
199
+ platform: macos-aarch64
200
+ - os: windows-latest
201
+ platform: windows-x86_64
202
+ - os: ubuntu-latest
203
+ platform: sdist
204
+ steps:
205
+ - uses: actions/checkout@v4
206
+
207
+ - uses: actions/download-artifact@v4
208
+ with:
209
+ name: wheels-${{ matrix.platform }}
210
+ path: dist
211
+
212
+ - uses: actions/setup-python@v5
213
+ if: matrix.container == ''
214
+ with:
215
+ python-version: "3.x"
216
+
217
+ # --no-index: pip may only use the wheel built above. The sdist needs
218
+ # maturin from PyPI to build, so it is installed by path instead.
219
+ - name: Install and run
220
+ if: matrix.container == ''
221
+ shell: bash
222
+ env:
223
+ PLATFORM: ${{ matrix.platform }}
224
+ run: |
225
+ set -ex
226
+ if [ "$PLATFORM" = sdist ]; then
227
+ python -m pip install dist/*.tar.gz
228
+ else
229
+ python -m pip install --no-index --find-links dist swiftdoc
230
+ fi
231
+ sh scripts/wheel-smoke-test.sh
232
+
233
+ - name: Install and run (Alpine container)
234
+ if: matrix.container != ''
235
+ env:
236
+ IMAGE: ${{ matrix.container }}
237
+ run: |
238
+ docker run --rm -v "$PWD:/w" -w /w "$IMAGE" sh -c \
239
+ 'pip install --root-user-action=ignore --no-index --find-links dist swiftdoc && sh scripts/wheel-smoke-test.sh'
240
+
241
+ # PyPI trusted publishing, so no token is stored. The PyPI project
242
+ # `swiftdoc` trusts this file (release.yaml) running in the `pypi`
243
+ # environment of kura120/swiftdoc. `publish` is needed for its check that the
244
+ # tag matches the Cargo.toml version, which is also the wheel version.
245
+ publish-pypi:
246
+ name: Publish to PyPI
247
+ needs: [publish, wheel-test]
248
+ if: startsWith(github.ref, 'refs/tags/v')
249
+ runs-on: ubuntu-latest
250
+ environment:
251
+ name: pypi
252
+ url: https://pypi.org/project/swiftdoc/
253
+ permissions:
254
+ id-token: write
255
+ steps:
256
+ - uses: actions/download-artifact@v4
257
+ with:
258
+ pattern: wheels-*
259
+ path: dist
260
+ merge-multiple: true
261
+
262
+ - name: List distributions
263
+ run: ls -l dist
264
+
265
+ - uses: pypa/gh-action-pypi-publish@release/v1