You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's it! You now have beautiful documentation with clickable type links and syntax highlighting.
32
+
That's it! You now have documentation with clickable type links and syntax highlighting.
33
33
34
34
35
35
### Customization
@@ -47,6 +47,8 @@ The above will generate standard code documentation, internal and test is exclud
47
47
48
48
It also resolves both internal and external type references and make clickable asciidoc links to those types. When _highlighter_ is set to `goasciidoc` even the function signatures are nicely highlighted with links to referenced types (otherwise those are standar source, go blocks with no links).
49
49
50
+
Need to skip generated or scratch folders? Add one or more `--exclude` filters. Use regexes or the `glb:` shorthand, e.g. `--exclude 'glb:**/.temp-files/**'` (_glb:_ tries to translate _glob_ expression to _regex_).
51
+
50
52
It also will render structs as JSON (example) when `--render struct-json` is set. Supported renderers are:
51
53
52
54
-`struct-json`: Renders structs as JSON
@@ -111,8 +113,8 @@ You may now use the `goasciidoc` e.g. in the `goasciidoc` repo by `goasciidoc --
PATH Directory or files to be included in scan (if none, current path is used)
@@ -141,6 +143,8 @@ Options:
141
143
--templatedir TEMPLATEDIR
142
144
Loads template files *.gtpl from a directory, use --list to get valid names of templates
143
145
--type-links MODE Controls type reference linking: disabled, internal, or external (default disabled)
146
+
--sub-module MODE Submodule processing mode: none, single, or separate (default none)
147
+
--package-mode MODE Package-level rendering mode: none, include, or link (default none)
144
148
--highlighter NAME Source code highlighter to use; available: none, goasciidoc
145
149
--help, -h display this help and exit
146
150
--version display version and exit
@@ -150,6 +154,258 @@ Options:
150
154
151
155
When generating documentation, `goasciidoc` can now render hyperlinks for referenced Go types. Enable it with `--type-links internal` to link across types within the current module, or `--type-links external` to also point at [`pkg.go.dev`](https://pkg.go.dev/) for external packages. By default (`--type-links disabled`) type names are rendered as plain text, preserving the behaviour of earlier releases.
152
156
157
+
### Multi-Module & Workspace Support
158
+
159
+
`goasciidoc` fully supports Go workspaces and multi-module projects! It automatically discovers `go.work` files or recursively finds multiple `go.mod` files, giving you flexible documentation generation options.
160
+
161
+
#### Smart Discovery
162
+
163
+
`goasciidoc` intelligently discovers your project structure:
164
+
165
+
1. **Walks up** from the current directory (or `--module` path)
166
+
2. **Prefers `go.work`** over `go.mod` at each directory level
167
+
3. **Auto-discovers** all modules in your workspace
168
+
169
+
No configuration needed—it just works!
170
+
171
+
#### Generation Modes
172
+
173
+
Control how multi-module documentation is generated with the `--sub-module` flag:
174
+
175
+
##### None (Default)
176
+
```bash
177
+
goasciidoc
178
+
```
179
+
Original behavior—documents a single module only. Backward compatible with all existing projects.
180
+
181
+
##### Single Mode (Merged)
182
+
```bash
183
+
goasciidoc --sub-module=single -o docs.adoc
184
+
```
185
+
Merges all workspace modules into **one unified document**. Perfect for:
186
+
- Getting a complete overview of your workspace
187
+
- Creating comprehensive API documentation
188
+
- Generating a single file for distribution
189
+
190
+
**Output:**`docs.adoc` (contains all modules with clear section breaks)
191
+
192
+
##### Separate Mode (Per-Module Files)
193
+
```bash
194
+
goasciidoc --sub-module=separate -o api-docs
195
+
```
196
+
Generates **separate documentation files**for each module. Ideal for:
197
+
- Large workspaces with independent modules
198
+
- Modular documentation that can be distributed separately
199
+
- Projects where each module has distinct audiences
200
+
201
+
**Output:**`api-docs-module1.adoc`, `api-docs-module2.adoc`, etc.
202
+
203
+
#### Cross-Module Type Linking
204
+
205
+
When using `--type-links internal` with multi-module projects, types automatically reference each other:
206
+
207
+
```bash
208
+
# Single mode: Uses anchor links within the same document
This makes it easy to understand the structure of complex workspaces.
281
+
282
+
### Package-Level Rendering
283
+
284
+
`goasciidoc` can generate separate documentation files for each package, creating a modular, navigable documentation structure. This is perfect for large projects where you want each package to have its own standalone documentation file.
285
+
286
+
#### Package Modes
287
+
288
+
Control package-level documentation with the `--package-mode` flag:
289
+
290
+
##### None (Default)
291
+
```bash
292
+
goasciidoc
293
+
```
294
+
Standard behavior—generates a single documentation file with all packages inline. Compatible with existing workflows.
295
+
296
+
##### Include Mode (Package per File + Master Index)
This creates package-level documentation for**all packages** across **all modules**in your workspace!
389
+
390
+
#### Real-World Example
391
+
392
+
```bash
393
+
# Complete package-level documentation with all features
394
+
goasciidoc \
395
+
--package-mode=include \
396
+
--type-links=internal \
397
+
--highlighter=goasciidoc \
398
+
--render struct-json \
399
+
-o docs/api-index.adoc
400
+
401
+
# Result:
402
+
# - docs/api-index.adoc (master index)
403
+
# - docs/packages/*.adoc (one file per package)
404
+
# - Cross-referenced types between packages
405
+
# - Syntax highlighting
406
+
# - JSON struct examples
407
+
```
408
+
153
409
## Overriding Default Package Overview
154
410
By default `goasciidoc` will use _overview.adoc_ or _\_design/overview.adoc_ to generate the package overview. If those are not found, it will default back to the _golang_ package documentation (if any).
0 commit comments