├── .copr
└── Makefile
├── .github
└── workflows
│ ├── pages.yml
│ └── rust-test.yml
├── .gitignore
├── .lock
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Cargo.lock
├── Cargo.toml
├── DCO.md
├── Dockerfile
├── Dockerfile-distro
├── LICENSE
├── PACKAGING.md
├── README.md
├── build.rs
├── docs
├── assembly_generating-documentation-files.adoc
├── con_configuration-files.adoc
├── proc_creating-a-new-assembly.adoc
├── proc_creating-a-new-module.adoc
├── proc_creating-a-new-snippet-file.adoc
├── proc_installing-newdoc.adoc
├── proc_overwriting-existing-files.adoc
├── proc_updating-newdoc.adoc
├── ref_options.adoc
└── using-newdoc.adoc
├── newdoc.spec
├── src
├── cmd_line.rs
├── config.rs
├── lib.rs
├── logging.rs
├── main.rs
├── module.rs
├── templating.rs
└── write.rs
├── templates
├── README.md
├── assembly.adoc
├── concept.adoc
├── procedure.adoc
├── reference.adoc
└── snippet.adoc
└── tests
├── generated
├── README.md
├── assembly_testing-that-an-assembly-forms-properly.adoc
├── con_a-title-that-tests-a-concept.adoc
├── minimal-assembly.adoc
├── minimal-concept.adoc
├── minimal-procedure.adoc
├── minimal-reference.adoc
├── minimal-snippet.adoc
├── proc_testing-a-procedure.adoc
├── ref_the-lines-in-a-reference-module.adoc
└── snip_some-notes-in-a-snippet-file.adoc
└── integration.rs
/.copr/Makefile:
--------------------------------------------------------------------------------
1 | srpm:
2 | dnf install -y rpmdevtools cargo
3 | rpmdev-setuptree
4 | cargo package
5 | mv target/package/*.crate ~/rpmbuild/SOURCES/
6 | cp newdoc.spec ~/rpmbuild/SPECS/
7 | rpmbuild -bs ~/rpmbuild/SPECS/newdoc.spec
8 | cp ~/rpmbuild/SRPMS/newdoc-*.src.rpm $(outdir)
9 |
--------------------------------------------------------------------------------
/.github/workflows/pages.yml:
--------------------------------------------------------------------------------
1 | # Deploy AsciiDoc documentation to GitHub Pages
2 | name: Deploy documentation to Pages
3 |
4 | on:
5 | # Runs on pushes targeting the default branch
6 | push:
7 | branches: ["main"]
8 |
9 | # Allows you to run this workflow manually from the Actions tab
10 | workflow_dispatch:
11 |
12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13 | permissions:
14 | contents: read
15 | pages: write
16 | id-token: write
17 |
18 | # Allow one concurrent deployment
19 | concurrency:
20 | group: "pages"
21 | cancel-in-progress: true
22 |
23 | jobs:
24 | # Build and publish the documentation
25 | deploy:
26 | environment:
27 | name: github-pages
28 | url: ${{ steps.deployment.outputs.page_url }}
29 | runs-on: ubuntu-latest
30 | container: asciidoctor/docker-asciidoctor
31 | steps:
32 | - name: Checkout
33 | uses: actions/checkout@v4
34 | # The asciidoctor container is built on Alpine and contains only a Busybox tar.
35 | # Github Actions need GNU tar for its options.
36 | - name: Install tar
37 | run: apk add tar
38 | - name: Build documentation
39 | run: asciidoctor --safe -vn docs/using-newdoc.adoc --out-file=docs/index.html
40 | - name: Setup Pages
41 | uses: actions/configure-pages@v5
42 | - name: Upload artifact
43 | uses: actions/upload-pages-artifact@v3
44 | with:
45 | # Upload the generated HTML file
46 | path: 'docs'
47 | - name: Deploy to GitHub Pages
48 | id: deployment
49 | uses: actions/deploy-pages@v4
50 |
--------------------------------------------------------------------------------
/.github/workflows/rust-test.yml:
--------------------------------------------------------------------------------
1 | name: Rust tests
2 |
3 | on: [ push ]
4 |
5 | env:
6 | CARGO_TERM_COLOR: always
7 |
8 | jobs:
9 | test:
10 |
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v3
15 | - name: Check syntax
16 | run: cargo check
17 | - name: Run tests
18 | run: cargo test
19 | - name: Check lints
20 | run: cargo clippy
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /*.adoc
3 | newdoc.1
4 | .vscode
5 |
--------------------------------------------------------------------------------
/.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redhat-documentation/newdoc/c88417140dfb6d931b285c719b4377b3b38778ee/.lock
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | The following is a summary of changes in each `newdoc` release, which is also a Git tag by the same name in this repository.
4 |
5 | ## v2.18.4
6 |
7 | * Update modular templates to synchronize with [modular-docs/pull/236](https://github.com/redhat-documentation/modular-docs/pull/236)
8 | * Update dependencies
9 |
10 | ## v2.18.3
11 |
12 | * Update dependencies
13 |
14 | ## v2.18.2
15 |
16 | * Previously, newdoc didn't recognize configuration files in your Git repository when you entered its sub-directories. This is now fixed, and newdoc can detect configuration files even from sub-directories. See [RHELDOCS-17915](https://issues.redhat.com/browse/RHELDOCS-17915).
17 |
18 | ## v2.18.1
19 |
20 | * Fix the `--no-file-prefixes` (`-P`) option. Previously, the option didn't have the expected effect, and instead, it disabled comments.
21 |
22 | ## v2.18.0
23 |
24 | * An option to generate files without the metadata attributes header. See [issue #45](https://github.com/redhat-documentation/newdoc/issues/45).
25 |
26 | ## v2.17.0
27 |
28 | * Enable configuration files. [See the documentation](https://redhat-documentation.github.io/newdoc/#_configuration_files). [Issue #20](https://github.com/redhat-documentation/newdoc/issues/20)
29 | * Remove the outdated `abstract` tag from all templates. [Issue #40](https://github.com/redhat-documentation/newdoc/issues/40)
30 | * Update various dependencies.
31 |
32 | ## v2.16.0
33 |
34 | * Enable the `--simplified` option to generate files without the `context` attribute. See [issue #31](https://github.com/redhat-documentation/newdoc/issues/31).
35 | * Update various dependencies.
36 |
37 | ## v2.15.1
38 |
39 | * Properly follow the `YYYY-MM-DD` date format. Fixes [issue #39](https://github.com/redhat-documentation/newdoc/issues/39).
40 | * Update various dependencies.
41 |
42 | ## v2.15.0
43 |
44 | * Add metadata in the generated files that specify which newdoc version generated the document and the date that it was generated.
45 | * Build the RPM using rustup to work around the outdated toolchain on RHEL.
46 |
47 | ## v2.14.1
48 |
49 | * Rename `_content-type` to `_mod-docs-content-type`. See [issue #37](https://github.com/redhat-documentation/newdoc/issues/37).
50 |
51 | ## v2.14.0
52 |
53 | * Update modular templates to synchronize with [modular-docs/pull/208](https://github.com/redhat-documentation/modular-docs/pull/208/).
54 | * Remove the legacy, deprecated `--validate` (`-l`) option. Please use Enki instead: .
55 | * The command-line options parser previously disabled snippets by mistake. Fix and re-enable them.
56 | * Switch the main container to the Alpine base from UBI Micro.
57 | * Update various dependencies.
58 |
59 | ## v2.13.1
60 |
61 | * The help message and the man page now specify that the validation feature is deprecated. See [#36](https://github.com/redhat-documentation/newdoc/issues/36).
62 |
63 | ## v2.13.0
64 |
65 | * By default, the generated files do not contain any comments. The `--no-comments` (`-C`) option is now deprecated and has no effect. You can use the new `--comments` (`-M`) option to generate files with the comments that were previously the default.
66 |
67 | ## v2.12.0
68 |
69 | * Deprecate the `--validate` (`-l`) option. Please use `enki` instead: .
70 | * Switch to the `bpaf` command-line argument parser.
71 |
72 | ## v2.11.0
73 |
74 | * Separate options for the module type prefix in IDs (anchors) and file names.
75 |
76 | ## v2.10.6
77 |
78 | * A prettier confirmation prompt when overwriting a file.
79 |
80 | ## v2.10.5
81 |
82 | * Update the modular templates to the latest upstream version.
83 |
84 | ## v2.10.4
85 |
86 | * Improvements to error handling and reporting.
87 |
88 | ## v2.10.3
89 |
90 | * Validation: Jupiter now supports attributes in titles.
91 | * Remove the `--detect-directory` option, which has been the default behavior.
92 | * Minor internal changes.
93 |
94 | ## v2.10.2
95 |
96 | * Sanitize non-ASCII characters in the module ID ([#33](https://github.com/redhat-documentation/newdoc/issues/33)).
97 | * No longer check for the `experimental` attribute, which isn't required anymore.
98 |
99 | ## v2.10.1
100 |
101 | * Fix an ID bug reported by Marc Muehlfeld.
102 |
103 | ## v2.10.0
104 |
105 | * Enable generating the snippet file type.
106 |
107 | ## v2.9.8
108 |
109 | * Remove the abstract tag from the templates. Jupiter doesn't require it.
110 | * No longer report a missing abstract tag in validation
111 |
112 | ## v2.9.7
113 |
114 | * The `--validate` option can take multiple values.
115 |
116 | ## v2.9.6
117 |
118 | * No longer validate that xrefs are path-based; Jupiter does not require them
119 | * Changes to error handling
120 |
121 | ## v2.9.5
122 |
123 | * Check that each module name is a single string
124 | * Various internal improvements and documentation fixes
125 |
126 | ## v2.9.4
127 |
128 | * Rename the `:_module-type:` attribute to `:_content-type:`
129 |
130 | ## v2.9.3
131 |
132 | * Validation: Report when no issues have been found.
133 | * Improve the documentation in the readme.
134 |
135 | ## v2.9.2
136 |
137 | * Validation: Use a slightly more robust detection of path-based xrefs.
138 |
139 | ## v2.9.1
140 |
141 | * Validation: Check that supported xrefs are path-based.
142 |
143 | ## v2.9.0
144 |
145 | * Add a validation (linting) functionality using the `--validate` option.
146 |
147 | ## v2.8.3
148 |
149 | * Update the modular templates to match upstream changes
150 |
151 | ## v2.8.2
152 |
153 | * Add the module type attributes; Issue #18
154 | * Remove the blank line after 'Additional resources' in the assembly, which caused issues with Pantheon 2
155 |
156 | ## v2.8.1
157 |
158 | * Update the modular templates to match upstream changes
159 |
160 | ## v2.8.0
161 |
162 | * Use a standardized syntax for configuring the templates (askama).
163 | * Remove extra blank lines from the generated files.
164 |
165 | ## v2.7.0
166 |
167 | * Attempt to fill in the full include path by default. This obsoletes the `--detect-directory` option. Issue #16
168 | * Use a more standardizedterminal logging solution. You can now set the verbosity level.
169 |
170 | ## v2.6.4
171 |
172 | * Update the modular templates.
173 |
174 | ## v2.6.3
175 |
176 | * Update the crates that newdoc depends on.
177 |
178 | ## v2.6.2
179 |
180 | * Bug fix: With the --no-comments option, remove all multi-line comments, not just the first one
181 |
182 | ## v2.6.1
183 |
184 | * Change the assembly prerequisites to a numbered heading in accordance with modular-docs #134
185 | * Small internal changes
186 |
187 | ## v2.6.0
188 |
189 | * The templates have been updated with Patheon 2 metadata
190 | * The generated IDs now start with a module type prefix, matching the new templates
191 |
192 | ## v2.5.0
193 |
194 | * Add the `--no-examples` option
195 | * Recognize block AsciiDoc comments in the templates
196 | * Add first unit tests
197 |
198 | ## v2.4.0
199 |
200 | * Optionally detect and fill out the include path
201 | * Refactoring the code into smaller modules
202 |
203 | ## v2.3.5
204 |
205 | * Deduplicate app metadata
206 |
207 | ## v2.3.4
208 |
209 | * Updated README
210 | * New packaging options
211 | * Enabled CI
212 |
213 | ## v2.3.3
214 |
215 | * Make context in assembly IDs optional and conditional
216 |
217 | ## v2.3.2
218 |
219 | * Align the Optional formatting with the IBM Style Guide; #8
220 |
221 | ## v2.3.1
222 |
223 | * Use colors instead of emoji for highlighting in the output
224 |
225 | ## v2.3.0 and earlier
226 |
227 | No changelog. See the commit messages between the Git tags.
228 |
229 | ## v2.0.0
230 |
231 | Initial release of `newdoc` rewritten in the Rust language.
232 |
233 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Certificate of Origin
2 |
3 | By contributing to this project you agree to the Developer Certificate of Origin (DCO). This document was created by the Linux Kernel community and is a simple statement that you, as a contributor, have the legal right to make the contribution. See the [DCO.md](DCO.md) file for details.
4 |
5 |
--------------------------------------------------------------------------------
/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 3
4 |
5 | [[package]]
6 | name = "addr2line"
7 | version = "0.24.2"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
10 | dependencies = [
11 | "gimli",
12 | ]
13 |
14 | [[package]]
15 | name = "adler2"
16 | version = "2.0.0"
17 | source = "registry+https://github.com/rust-lang/crates.io-index"
18 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
19 |
20 | [[package]]
21 | name = "aho-corasick"
22 | version = "1.1.3"
23 | source = "registry+https://github.com/rust-lang/crates.io-index"
24 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
25 | dependencies = [
26 | "memchr",
27 | ]
28 |
29 | [[package]]
30 | name = "askama"
31 | version = "0.12.1"
32 | source = "registry+https://github.com/rust-lang/crates.io-index"
33 | checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
34 | dependencies = [
35 | "askama_derive",
36 | "askama_escape",
37 | "humansize",
38 | "num-traits",
39 | "percent-encoding",
40 | ]
41 |
42 | [[package]]
43 | name = "askama_derive"
44 | version = "0.12.5"
45 | source = "registry+https://github.com/rust-lang/crates.io-index"
46 | checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"
47 | dependencies = [
48 | "askama_parser",
49 | "basic-toml",
50 | "mime",
51 | "mime_guess",
52 | "proc-macro2",
53 | "quote",
54 | "serde",
55 | "syn",
56 | ]
57 |
58 | [[package]]
59 | name = "askama_escape"
60 | version = "0.10.3"
61 | source = "registry+https://github.com/rust-lang/crates.io-index"
62 | checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
63 |
64 | [[package]]
65 | name = "askama_parser"
66 | version = "0.2.1"
67 | source = "registry+https://github.com/rust-lang/crates.io-index"
68 | checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"
69 | dependencies = [
70 | "nom",
71 | ]
72 |
73 | [[package]]
74 | name = "atomic"
75 | version = "0.6.0"
76 | source = "registry+https://github.com/rust-lang/crates.io-index"
77 | checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994"
78 | dependencies = [
79 | "bytemuck",
80 | ]
81 |
82 | [[package]]
83 | name = "autocfg"
84 | version = "1.4.0"
85 | source = "registry+https://github.com/rust-lang/crates.io-index"
86 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
87 |
88 | [[package]]
89 | name = "backtrace"
90 | version = "0.3.75"
91 | source = "registry+https://github.com/rust-lang/crates.io-index"
92 | checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
93 | dependencies = [
94 | "addr2line",
95 | "cfg-if",
96 | "libc",
97 | "miniz_oxide",
98 | "object",
99 | "rustc-demangle",
100 | "windows-targets 0.52.6",
101 | ]
102 |
103 | [[package]]
104 | name = "basic-toml"
105 | version = "0.1.10"
106 | source = "registry+https://github.com/rust-lang/crates.io-index"
107 | checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
108 | dependencies = [
109 | "serde",
110 | ]
111 |
112 | [[package]]
113 | name = "bitflags"
114 | version = "2.9.1"
115 | source = "registry+https://github.com/rust-lang/crates.io-index"
116 | checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
117 |
118 | [[package]]
119 | name = "bpaf"
120 | version = "0.9.20"
121 | source = "registry+https://github.com/rust-lang/crates.io-index"
122 | checksum = "473976d7a8620bb1e06dcdd184407c2363fe4fec8e983ee03ed9197222634a31"
123 | dependencies = [
124 | "bpaf_derive",
125 | "owo-colors",
126 | "supports-color",
127 | ]
128 |
129 | [[package]]
130 | name = "bpaf_derive"
131 | version = "0.5.17"
132 | source = "registry+https://github.com/rust-lang/crates.io-index"
133 | checksum = "fefb4feeec9a091705938922f26081aad77c64cd2e76cd1c4a9ece8e42e1618a"
134 | dependencies = [
135 | "proc-macro2",
136 | "quote",
137 | "syn",
138 | ]
139 |
140 | [[package]]
141 | name = "bytemuck"
142 | version = "1.23.0"
143 | source = "registry+https://github.com/rust-lang/crates.io-index"
144 | checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
145 |
146 | [[package]]
147 | name = "cfg-if"
148 | version = "1.0.0"
149 | source = "registry+https://github.com/rust-lang/crates.io-index"
150 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
151 |
152 | [[package]]
153 | name = "color-eyre"
154 | version = "0.6.4"
155 | source = "registry+https://github.com/rust-lang/crates.io-index"
156 | checksum = "e6e1761c0e16f8883bbbb8ce5990867f4f06bf11a0253da6495a04ce4b6ef0ec"
157 | dependencies = [
158 | "backtrace",
159 | "eyre",
160 | "indenter",
161 | "once_cell",
162 | "owo-colors",
163 | ]
164 |
165 | [[package]]
166 | name = "console"
167 | version = "0.15.11"
168 | source = "registry+https://github.com/rust-lang/crates.io-index"
169 | checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8"
170 | dependencies = [
171 | "encode_unicode",
172 | "libc",
173 | "once_cell",
174 | "unicode-width",
175 | "windows-sys 0.59.0",
176 | ]
177 |
178 | [[package]]
179 | name = "deranged"
180 | version = "0.4.0"
181 | source = "registry+https://github.com/rust-lang/crates.io-index"
182 | checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
183 | dependencies = [
184 | "powerfmt",
185 | ]
186 |
187 | [[package]]
188 | name = "dialoguer"
189 | version = "0.11.0"
190 | source = "registry+https://github.com/rust-lang/crates.io-index"
191 | checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de"
192 | dependencies = [
193 | "console",
194 | "shell-words",
195 | "tempfile",
196 | "thiserror",
197 | "zeroize",
198 | ]
199 |
200 | [[package]]
201 | name = "directories"
202 | version = "5.0.1"
203 | source = "registry+https://github.com/rust-lang/crates.io-index"
204 | checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35"
205 | dependencies = [
206 | "dirs-sys",
207 | ]
208 |
209 | [[package]]
210 | name = "dirs-sys"
211 | version = "0.4.1"
212 | source = "registry+https://github.com/rust-lang/crates.io-index"
213 | checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
214 | dependencies = [
215 | "libc",
216 | "option-ext",
217 | "redox_users",
218 | "windows-sys 0.48.0",
219 | ]
220 |
221 | [[package]]
222 | name = "encode_unicode"
223 | version = "1.0.0"
224 | source = "registry+https://github.com/rust-lang/crates.io-index"
225 | checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
226 |
227 | [[package]]
228 | name = "equivalent"
229 | version = "1.0.2"
230 | source = "registry+https://github.com/rust-lang/crates.io-index"
231 | checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
232 |
233 | [[package]]
234 | name = "errno"
235 | version = "0.3.12"
236 | source = "registry+https://github.com/rust-lang/crates.io-index"
237 | checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18"
238 | dependencies = [
239 | "libc",
240 | "windows-sys 0.59.0",
241 | ]
242 |
243 | [[package]]
244 | name = "eyre"
245 | version = "0.6.12"
246 | source = "registry+https://github.com/rust-lang/crates.io-index"
247 | checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
248 | dependencies = [
249 | "indenter",
250 | "once_cell",
251 | ]
252 |
253 | [[package]]
254 | name = "fastrand"
255 | version = "2.3.0"
256 | source = "registry+https://github.com/rust-lang/crates.io-index"
257 | checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
258 |
259 | [[package]]
260 | name = "figment"
261 | version = "0.10.19"
262 | source = "registry+https://github.com/rust-lang/crates.io-index"
263 | checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3"
264 | dependencies = [
265 | "atomic",
266 | "serde",
267 | "toml",
268 | "uncased",
269 | "version_check",
270 | ]
271 |
272 | [[package]]
273 | name = "getrandom"
274 | version = "0.2.16"
275 | source = "registry+https://github.com/rust-lang/crates.io-index"
276 | checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
277 | dependencies = [
278 | "cfg-if",
279 | "libc",
280 | "wasi 0.11.0+wasi-snapshot-preview1",
281 | ]
282 |
283 | [[package]]
284 | name = "getrandom"
285 | version = "0.3.3"
286 | source = "registry+https://github.com/rust-lang/crates.io-index"
287 | checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
288 | dependencies = [
289 | "cfg-if",
290 | "libc",
291 | "r-efi",
292 | "wasi 0.14.2+wasi-0.2.4",
293 | ]
294 |
295 | [[package]]
296 | name = "gimli"
297 | version = "0.31.1"
298 | source = "registry+https://github.com/rust-lang/crates.io-index"
299 | checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
300 |
301 | [[package]]
302 | name = "hashbrown"
303 | version = "0.15.3"
304 | source = "registry+https://github.com/rust-lang/crates.io-index"
305 | checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
306 |
307 | [[package]]
308 | name = "humansize"
309 | version = "2.1.3"
310 | source = "registry+https://github.com/rust-lang/crates.io-index"
311 | checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
312 | dependencies = [
313 | "libm",
314 | ]
315 |
316 | [[package]]
317 | name = "indenter"
318 | version = "0.3.3"
319 | source = "registry+https://github.com/rust-lang/crates.io-index"
320 | checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
321 |
322 | [[package]]
323 | name = "indexmap"
324 | version = "2.9.0"
325 | source = "registry+https://github.com/rust-lang/crates.io-index"
326 | checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
327 | dependencies = [
328 | "equivalent",
329 | "hashbrown",
330 | ]
331 |
332 | [[package]]
333 | name = "is_ci"
334 | version = "1.2.0"
335 | source = "registry+https://github.com/rust-lang/crates.io-index"
336 | checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45"
337 |
338 | [[package]]
339 | name = "itoa"
340 | version = "1.0.15"
341 | source = "registry+https://github.com/rust-lang/crates.io-index"
342 | checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
343 |
344 | [[package]]
345 | name = "libc"
346 | version = "0.2.172"
347 | source = "registry+https://github.com/rust-lang/crates.io-index"
348 | checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
349 |
350 | [[package]]
351 | name = "libm"
352 | version = "0.2.15"
353 | source = "registry+https://github.com/rust-lang/crates.io-index"
354 | checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
355 |
356 | [[package]]
357 | name = "libredox"
358 | version = "0.1.3"
359 | source = "registry+https://github.com/rust-lang/crates.io-index"
360 | checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
361 | dependencies = [
362 | "bitflags",
363 | "libc",
364 | ]
365 |
366 | [[package]]
367 | name = "linux-raw-sys"
368 | version = "0.9.4"
369 | source = "registry+https://github.com/rust-lang/crates.io-index"
370 | checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
371 |
372 | [[package]]
373 | name = "log"
374 | version = "0.4.27"
375 | source = "registry+https://github.com/rust-lang/crates.io-index"
376 | checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
377 |
378 | [[package]]
379 | name = "memchr"
380 | version = "2.7.4"
381 | source = "registry+https://github.com/rust-lang/crates.io-index"
382 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
383 |
384 | [[package]]
385 | name = "mime"
386 | version = "0.3.17"
387 | source = "registry+https://github.com/rust-lang/crates.io-index"
388 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
389 |
390 | [[package]]
391 | name = "mime_guess"
392 | version = "2.0.5"
393 | source = "registry+https://github.com/rust-lang/crates.io-index"
394 | checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
395 | dependencies = [
396 | "mime",
397 | "unicase",
398 | ]
399 |
400 | [[package]]
401 | name = "minimal-lexical"
402 | version = "0.2.1"
403 | source = "registry+https://github.com/rust-lang/crates.io-index"
404 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
405 |
406 | [[package]]
407 | name = "miniz_oxide"
408 | version = "0.8.8"
409 | source = "registry+https://github.com/rust-lang/crates.io-index"
410 | checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a"
411 | dependencies = [
412 | "adler2",
413 | ]
414 |
415 | [[package]]
416 | name = "newdoc"
417 | version = "2.18.5"
418 | dependencies = [
419 | "askama",
420 | "bpaf",
421 | "color-eyre",
422 | "dialoguer",
423 | "directories",
424 | "figment",
425 | "log",
426 | "regex",
427 | "serde",
428 | "simplelog",
429 | "time",
430 | ]
431 |
432 | [[package]]
433 | name = "nom"
434 | version = "7.1.3"
435 | source = "registry+https://github.com/rust-lang/crates.io-index"
436 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
437 | dependencies = [
438 | "memchr",
439 | "minimal-lexical",
440 | ]
441 |
442 | [[package]]
443 | name = "num-conv"
444 | version = "0.1.0"
445 | source = "registry+https://github.com/rust-lang/crates.io-index"
446 | checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
447 |
448 | [[package]]
449 | name = "num-traits"
450 | version = "0.2.19"
451 | source = "registry+https://github.com/rust-lang/crates.io-index"
452 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
453 | dependencies = [
454 | "autocfg",
455 | ]
456 |
457 | [[package]]
458 | name = "num_threads"
459 | version = "0.1.7"
460 | source = "registry+https://github.com/rust-lang/crates.io-index"
461 | checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
462 | dependencies = [
463 | "libc",
464 | ]
465 |
466 | [[package]]
467 | name = "object"
468 | version = "0.36.7"
469 | source = "registry+https://github.com/rust-lang/crates.io-index"
470 | checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
471 | dependencies = [
472 | "memchr",
473 | ]
474 |
475 | [[package]]
476 | name = "once_cell"
477 | version = "1.21.3"
478 | source = "registry+https://github.com/rust-lang/crates.io-index"
479 | checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
480 |
481 | [[package]]
482 | name = "option-ext"
483 | version = "0.2.0"
484 | source = "registry+https://github.com/rust-lang/crates.io-index"
485 | checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
486 |
487 | [[package]]
488 | name = "owo-colors"
489 | version = "4.2.1"
490 | source = "registry+https://github.com/rust-lang/crates.io-index"
491 | checksum = "26995317201fa17f3656c36716aed4a7c81743a9634ac4c99c0eeda495db0cec"
492 |
493 | [[package]]
494 | name = "percent-encoding"
495 | version = "2.3.1"
496 | source = "registry+https://github.com/rust-lang/crates.io-index"
497 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
498 |
499 | [[package]]
500 | name = "powerfmt"
501 | version = "0.2.0"
502 | source = "registry+https://github.com/rust-lang/crates.io-index"
503 | checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
504 |
505 | [[package]]
506 | name = "proc-macro2"
507 | version = "1.0.95"
508 | source = "registry+https://github.com/rust-lang/crates.io-index"
509 | checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
510 | dependencies = [
511 | "unicode-ident",
512 | ]
513 |
514 | [[package]]
515 | name = "quote"
516 | version = "1.0.40"
517 | source = "registry+https://github.com/rust-lang/crates.io-index"
518 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
519 | dependencies = [
520 | "proc-macro2",
521 | ]
522 |
523 | [[package]]
524 | name = "r-efi"
525 | version = "5.2.0"
526 | source = "registry+https://github.com/rust-lang/crates.io-index"
527 | checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
528 |
529 | [[package]]
530 | name = "redox_users"
531 | version = "0.4.6"
532 | source = "registry+https://github.com/rust-lang/crates.io-index"
533 | checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
534 | dependencies = [
535 | "getrandom 0.2.16",
536 | "libredox",
537 | "thiserror",
538 | ]
539 |
540 | [[package]]
541 | name = "regex"
542 | version = "1.11.1"
543 | source = "registry+https://github.com/rust-lang/crates.io-index"
544 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
545 | dependencies = [
546 | "aho-corasick",
547 | "memchr",
548 | "regex-automata",
549 | "regex-syntax",
550 | ]
551 |
552 | [[package]]
553 | name = "regex-automata"
554 | version = "0.4.9"
555 | source = "registry+https://github.com/rust-lang/crates.io-index"
556 | checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
557 | dependencies = [
558 | "aho-corasick",
559 | "memchr",
560 | "regex-syntax",
561 | ]
562 |
563 | [[package]]
564 | name = "regex-syntax"
565 | version = "0.8.5"
566 | source = "registry+https://github.com/rust-lang/crates.io-index"
567 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
568 |
569 | [[package]]
570 | name = "rustc-demangle"
571 | version = "0.1.24"
572 | source = "registry+https://github.com/rust-lang/crates.io-index"
573 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
574 |
575 | [[package]]
576 | name = "rustix"
577 | version = "1.0.7"
578 | source = "registry+https://github.com/rust-lang/crates.io-index"
579 | checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
580 | dependencies = [
581 | "bitflags",
582 | "errno",
583 | "libc",
584 | "linux-raw-sys",
585 | "windows-sys 0.59.0",
586 | ]
587 |
588 | [[package]]
589 | name = "serde"
590 | version = "1.0.219"
591 | source = "registry+https://github.com/rust-lang/crates.io-index"
592 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
593 | dependencies = [
594 | "serde_derive",
595 | ]
596 |
597 | [[package]]
598 | name = "serde_derive"
599 | version = "1.0.219"
600 | source = "registry+https://github.com/rust-lang/crates.io-index"
601 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
602 | dependencies = [
603 | "proc-macro2",
604 | "quote",
605 | "syn",
606 | ]
607 |
608 | [[package]]
609 | name = "serde_spanned"
610 | version = "0.6.8"
611 | source = "registry+https://github.com/rust-lang/crates.io-index"
612 | checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
613 | dependencies = [
614 | "serde",
615 | ]
616 |
617 | [[package]]
618 | name = "shell-words"
619 | version = "1.1.0"
620 | source = "registry+https://github.com/rust-lang/crates.io-index"
621 | checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
622 |
623 | [[package]]
624 | name = "simplelog"
625 | version = "0.12.2"
626 | source = "registry+https://github.com/rust-lang/crates.io-index"
627 | checksum = "16257adbfaef1ee58b1363bdc0664c9b8e1e30aed86049635fb5f147d065a9c0"
628 | dependencies = [
629 | "log",
630 | "termcolor",
631 | "time",
632 | ]
633 |
634 | [[package]]
635 | name = "supports-color"
636 | version = "3.0.2"
637 | source = "registry+https://github.com/rust-lang/crates.io-index"
638 | checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6"
639 | dependencies = [
640 | "is_ci",
641 | ]
642 |
643 | [[package]]
644 | name = "syn"
645 | version = "2.0.101"
646 | source = "registry+https://github.com/rust-lang/crates.io-index"
647 | checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
648 | dependencies = [
649 | "proc-macro2",
650 | "quote",
651 | "unicode-ident",
652 | ]
653 |
654 | [[package]]
655 | name = "tempfile"
656 | version = "3.20.0"
657 | source = "registry+https://github.com/rust-lang/crates.io-index"
658 | checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
659 | dependencies = [
660 | "fastrand",
661 | "getrandom 0.3.3",
662 | "once_cell",
663 | "rustix",
664 | "windows-sys 0.59.0",
665 | ]
666 |
667 | [[package]]
668 | name = "termcolor"
669 | version = "1.4.1"
670 | source = "registry+https://github.com/rust-lang/crates.io-index"
671 | checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
672 | dependencies = [
673 | "winapi-util",
674 | ]
675 |
676 | [[package]]
677 | name = "thiserror"
678 | version = "1.0.69"
679 | source = "registry+https://github.com/rust-lang/crates.io-index"
680 | checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
681 | dependencies = [
682 | "thiserror-impl",
683 | ]
684 |
685 | [[package]]
686 | name = "thiserror-impl"
687 | version = "1.0.69"
688 | source = "registry+https://github.com/rust-lang/crates.io-index"
689 | checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
690 | dependencies = [
691 | "proc-macro2",
692 | "quote",
693 | "syn",
694 | ]
695 |
696 | [[package]]
697 | name = "time"
698 | version = "0.3.41"
699 | source = "registry+https://github.com/rust-lang/crates.io-index"
700 | checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
701 | dependencies = [
702 | "deranged",
703 | "itoa",
704 | "libc",
705 | "num-conv",
706 | "num_threads",
707 | "powerfmt",
708 | "serde",
709 | "time-core",
710 | "time-macros",
711 | ]
712 |
713 | [[package]]
714 | name = "time-core"
715 | version = "0.1.4"
716 | source = "registry+https://github.com/rust-lang/crates.io-index"
717 | checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
718 |
719 | [[package]]
720 | name = "time-macros"
721 | version = "0.2.22"
722 | source = "registry+https://github.com/rust-lang/crates.io-index"
723 | checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
724 | dependencies = [
725 | "num-conv",
726 | "time-core",
727 | ]
728 |
729 | [[package]]
730 | name = "toml"
731 | version = "0.8.22"
732 | source = "registry+https://github.com/rust-lang/crates.io-index"
733 | checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
734 | dependencies = [
735 | "serde",
736 | "serde_spanned",
737 | "toml_datetime",
738 | "toml_edit",
739 | ]
740 |
741 | [[package]]
742 | name = "toml_datetime"
743 | version = "0.6.9"
744 | source = "registry+https://github.com/rust-lang/crates.io-index"
745 | checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
746 | dependencies = [
747 | "serde",
748 | ]
749 |
750 | [[package]]
751 | name = "toml_edit"
752 | version = "0.22.26"
753 | source = "registry+https://github.com/rust-lang/crates.io-index"
754 | checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
755 | dependencies = [
756 | "indexmap",
757 | "serde",
758 | "serde_spanned",
759 | "toml_datetime",
760 | "toml_write",
761 | "winnow",
762 | ]
763 |
764 | [[package]]
765 | name = "toml_write"
766 | version = "0.1.1"
767 | source = "registry+https://github.com/rust-lang/crates.io-index"
768 | checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
769 |
770 | [[package]]
771 | name = "uncased"
772 | version = "0.9.10"
773 | source = "registry+https://github.com/rust-lang/crates.io-index"
774 | checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697"
775 | dependencies = [
776 | "version_check",
777 | ]
778 |
779 | [[package]]
780 | name = "unicase"
781 | version = "2.8.1"
782 | source = "registry+https://github.com/rust-lang/crates.io-index"
783 | checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
784 |
785 | [[package]]
786 | name = "unicode-ident"
787 | version = "1.0.18"
788 | source = "registry+https://github.com/rust-lang/crates.io-index"
789 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
790 |
791 | [[package]]
792 | name = "unicode-width"
793 | version = "0.2.0"
794 | source = "registry+https://github.com/rust-lang/crates.io-index"
795 | checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
796 |
797 | [[package]]
798 | name = "version_check"
799 | version = "0.9.5"
800 | source = "registry+https://github.com/rust-lang/crates.io-index"
801 | checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
802 |
803 | [[package]]
804 | name = "wasi"
805 | version = "0.11.0+wasi-snapshot-preview1"
806 | source = "registry+https://github.com/rust-lang/crates.io-index"
807 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
808 |
809 | [[package]]
810 | name = "wasi"
811 | version = "0.14.2+wasi-0.2.4"
812 | source = "registry+https://github.com/rust-lang/crates.io-index"
813 | checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
814 | dependencies = [
815 | "wit-bindgen-rt",
816 | ]
817 |
818 | [[package]]
819 | name = "winapi-util"
820 | version = "0.1.9"
821 | source = "registry+https://github.com/rust-lang/crates.io-index"
822 | checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
823 | dependencies = [
824 | "windows-sys 0.59.0",
825 | ]
826 |
827 | [[package]]
828 | name = "windows-sys"
829 | version = "0.48.0"
830 | source = "registry+https://github.com/rust-lang/crates.io-index"
831 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
832 | dependencies = [
833 | "windows-targets 0.48.5",
834 | ]
835 |
836 | [[package]]
837 | name = "windows-sys"
838 | version = "0.59.0"
839 | source = "registry+https://github.com/rust-lang/crates.io-index"
840 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
841 | dependencies = [
842 | "windows-targets 0.52.6",
843 | ]
844 |
845 | [[package]]
846 | name = "windows-targets"
847 | version = "0.48.5"
848 | source = "registry+https://github.com/rust-lang/crates.io-index"
849 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
850 | dependencies = [
851 | "windows_aarch64_gnullvm 0.48.5",
852 | "windows_aarch64_msvc 0.48.5",
853 | "windows_i686_gnu 0.48.5",
854 | "windows_i686_msvc 0.48.5",
855 | "windows_x86_64_gnu 0.48.5",
856 | "windows_x86_64_gnullvm 0.48.5",
857 | "windows_x86_64_msvc 0.48.5",
858 | ]
859 |
860 | [[package]]
861 | name = "windows-targets"
862 | version = "0.52.6"
863 | source = "registry+https://github.com/rust-lang/crates.io-index"
864 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
865 | dependencies = [
866 | "windows_aarch64_gnullvm 0.52.6",
867 | "windows_aarch64_msvc 0.52.6",
868 | "windows_i686_gnu 0.52.6",
869 | "windows_i686_gnullvm",
870 | "windows_i686_msvc 0.52.6",
871 | "windows_x86_64_gnu 0.52.6",
872 | "windows_x86_64_gnullvm 0.52.6",
873 | "windows_x86_64_msvc 0.52.6",
874 | ]
875 |
876 | [[package]]
877 | name = "windows_aarch64_gnullvm"
878 | version = "0.48.5"
879 | source = "registry+https://github.com/rust-lang/crates.io-index"
880 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
881 |
882 | [[package]]
883 | name = "windows_aarch64_gnullvm"
884 | version = "0.52.6"
885 | source = "registry+https://github.com/rust-lang/crates.io-index"
886 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
887 |
888 | [[package]]
889 | name = "windows_aarch64_msvc"
890 | version = "0.48.5"
891 | source = "registry+https://github.com/rust-lang/crates.io-index"
892 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
893 |
894 | [[package]]
895 | name = "windows_aarch64_msvc"
896 | version = "0.52.6"
897 | source = "registry+https://github.com/rust-lang/crates.io-index"
898 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
899 |
900 | [[package]]
901 | name = "windows_i686_gnu"
902 | version = "0.48.5"
903 | source = "registry+https://github.com/rust-lang/crates.io-index"
904 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
905 |
906 | [[package]]
907 | name = "windows_i686_gnu"
908 | version = "0.52.6"
909 | source = "registry+https://github.com/rust-lang/crates.io-index"
910 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
911 |
912 | [[package]]
913 | name = "windows_i686_gnullvm"
914 | version = "0.52.6"
915 | source = "registry+https://github.com/rust-lang/crates.io-index"
916 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
917 |
918 | [[package]]
919 | name = "windows_i686_msvc"
920 | version = "0.48.5"
921 | source = "registry+https://github.com/rust-lang/crates.io-index"
922 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
923 |
924 | [[package]]
925 | name = "windows_i686_msvc"
926 | version = "0.52.6"
927 | source = "registry+https://github.com/rust-lang/crates.io-index"
928 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
929 |
930 | [[package]]
931 | name = "windows_x86_64_gnu"
932 | version = "0.48.5"
933 | source = "registry+https://github.com/rust-lang/crates.io-index"
934 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
935 |
936 | [[package]]
937 | name = "windows_x86_64_gnu"
938 | version = "0.52.6"
939 | source = "registry+https://github.com/rust-lang/crates.io-index"
940 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
941 |
942 | [[package]]
943 | name = "windows_x86_64_gnullvm"
944 | version = "0.48.5"
945 | source = "registry+https://github.com/rust-lang/crates.io-index"
946 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
947 |
948 | [[package]]
949 | name = "windows_x86_64_gnullvm"
950 | version = "0.52.6"
951 | source = "registry+https://github.com/rust-lang/crates.io-index"
952 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
953 |
954 | [[package]]
955 | name = "windows_x86_64_msvc"
956 | version = "0.48.5"
957 | source = "registry+https://github.com/rust-lang/crates.io-index"
958 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
959 |
960 | [[package]]
961 | name = "windows_x86_64_msvc"
962 | version = "0.52.6"
963 | source = "registry+https://github.com/rust-lang/crates.io-index"
964 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
965 |
966 | [[package]]
967 | name = "winnow"
968 | version = "0.7.10"
969 | source = "registry+https://github.com/rust-lang/crates.io-index"
970 | checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec"
971 | dependencies = [
972 | "memchr",
973 | ]
974 |
975 | [[package]]
976 | name = "wit-bindgen-rt"
977 | version = "0.39.0"
978 | source = "registry+https://github.com/rust-lang/crates.io-index"
979 | checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
980 | dependencies = [
981 | "bitflags",
982 | ]
983 |
984 | [[package]]
985 | name = "zeroize"
986 | version = "1.8.1"
987 | source = "registry+https://github.com/rust-lang/crates.io-index"
988 | checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
989 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "newdoc"
3 | version = "2.18.5"
4 | description = "Generate pre-populated module files formatted with AsciiDoc that are used in Red Hat and Fedora documentation."
5 | authors = ["Marek Suchánek "]
6 | license = "GPL-3.0-or-later"
7 | edition = "2021"
8 | # Check the Rust version using `cargo msrv verify`.
9 | rust-version = "1.70"
10 | documentation = "https://docs.rs/newdoc"
11 | readme = "README.md"
12 | repository = "https://github.com/redhat-documentation/newdoc/"
13 | homepage = "https://redhat-documentation.github.io/newdoc/"
14 | categories = ["command-line-utilities", "text-processing"]
15 | keywords = ["asciidoc", "documentation", "RedHat"]
16 |
17 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
18 |
19 | [dependencies]
20 | bpaf = { version = "0.9", features = ["derive", "bright-color"]}
21 | regex = "1.10"
22 | log = "0.4"
23 | simplelog = "0.12"
24 | askama = "0.12"
25 | # Disable support for tracing_error and SpanTrace in eyre
26 | color-eyre = { version = "0.6", default-features = false }
27 | dialoguer = "0.11"
28 | time = "0.3"
29 | directories = "5.0"
30 | figment = { version = "0.10", features = ["toml"] }
31 | serde = { version = "1.0", features = ["derive"] }
32 |
33 | [build-dependencies]
34 | bpaf = { version = "0.9", features = ["derive", "docgen"]}
35 | time = "0.3"
36 | serde = { version = "1.0", features = ["derive"] }
37 |
--------------------------------------------------------------------------------
/DCO.md:
--------------------------------------------------------------------------------
1 | ## What is the DCO?
2 |
3 | The DCO is a certification normally associated with every contribution to a project made by every contributor. It signifies that the contributor has the right to submit the contribution under the applicable open source license of the project. The entire certification text (maintained by the Linux Foundation as version 1.1 at https://developercertificate.org/) is the following:
4 |
5 | By making a contribution to this project, I certify that:
6 |
7 | (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
8 |
9 | (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
10 |
11 | (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
12 |
13 | (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
14 |
15 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # See https://hub.docker.com/_/rust/
2 |
3 | # This version of the container is based on the Alpine distribution.
4 | # If you need the RHEL ecosystem, use the container defined in
5 | # the Dockerfile-distro file.
6 |
7 | FROM rust:alpine as builder
8 | WORKDIR /usr/src/newdoc
9 | COPY . .
10 | RUN apk update
11 | RUN apk add musl-dev
12 | RUN cargo install --path .
13 |
14 | FROM alpine:latest
15 | COPY --from=builder /usr/local/cargo/bin/newdoc /usr/local/bin/newdoc
16 | # When running this container interactively, use `-v .:/mnt/newdoc:Z`
17 | # to mount the current directory in the host to the container working dir.
18 | VOLUME ["/mnt/newdoc"]
19 | WORKDIR "/mnt/newdoc"
20 | CMD ["newdoc"]
21 |
--------------------------------------------------------------------------------
/Dockerfile-distro:
--------------------------------------------------------------------------------
1 | # See https://hub.docker.com/_/rust/
2 |
3 | # This version of the container includes a package manager,
4 | # if you need to extend the functionality in your workflow.
5 |
6 | FROM rust:latest as builder
7 | WORKDIR /usr/src/newdoc
8 | COPY . .
9 | RUN cargo install --path .
10 |
11 | FROM registry.access.redhat.com/ubi9-minimal:latest
12 | COPY --from=builder /usr/local/cargo/bin/newdoc /usr/local/bin/newdoc
13 | # When running this container interactively, use `-v .:/mnt/newdoc:Z`
14 | # to mount the current directory in the host to the container working dir.
15 | VOLUME ["/mnt/newdoc"]
16 | WORKDIR "/mnt/newdoc"
17 | CMD ["newdoc"]
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | newdoc
635 | Copyright (C) 2020 Marek Suchánek
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | newdoc Copyright (C) 2020 Marek Suchánek
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/PACKAGING.md:
--------------------------------------------------------------------------------
1 | # Packaging newdoc
2 |
3 | The following are instructions for the maintainers of `newdoc` to package and distribute new releases.
4 |
5 |
6 | ## Preparing a new version
7 |
8 | 1. Update newdoc dependencies:
9 |
10 | ```
11 | $ cargo update
12 | ```
13 |
14 | 2. Make your changes to the code and merge them to the `main` branch.
15 |
16 | 3. Update the version number in `Cargo.toml` and `newdoc.spec`. The versions must be identical.
17 |
18 | 4. Commit the version update:
19 |
20 | ```
21 | $ git commit -am "Update the version to X.Y.Z"
22 | ```
23 |
24 | 5. Tag the latest commit with the new version number:
25 |
26 | ```
27 | $ git tag -a vX.Y.Z -m "Version X.Y.Z"
28 | ```
29 |
30 | Make sure to prefix the version in the tag name with "v" for "version".
31 |
32 | 6. Push the version tag to the remote repository:
33 |
34 | ```
35 | $ git push --follow-tags
36 | ```
37 |
38 | If you're using several remote repositories, such as origin and upstream, make sure to push the tag to all of them.
39 |
40 |
41 | ## Packaging and distributing newdoc as an RPM package
42 |
43 | 1. Log into the Copr repository administration.
44 |
45 | Currently, newdoc is packaged in the [mmuehlfeldrh/newdoc-rs](https://copr.fedorainfracloud.org/coprs/mmuehlfeldrh/newdoc-rs/) repository.
46 |
47 | 2. Go to the **Builds** tab.
48 |
49 | 3. Click **New Build**.
50 |
51 | 4. Select **SCM**.
52 |
53 | 5. In the **Clone url** field, paste `https://github.com/redhat-documentation/newdoc`.
54 |
55 | 6. In the **Spec File** field, use `newdoc.spec`.
56 |
57 | 7. Click **Build**.
58 |
59 |
60 | ## Packaging and distributing newdoc with Homebrew
61 |
62 | 1. Make sure you have access to the existing Homebrew repository.
63 |
64 | Currently, newdoc is packaged in [redhat-documentation/homebrew-repo](https://github.com/redhat-documentation/homebrew-repo).
65 |
66 | 2. Download the `.tar.gz` archive that Github created for your latest tagged version:
67 |
68 |
69 |
70 | 3. Calculate the SHA256 checksum of this archive:
71 |
72 | ```
73 | $ sha256sum vX.Y.Z.tar.gz
74 | ```
75 |
76 | 4. In the `homebrew-repo` repository, edit the `Formula/newdoc.rb` file.
77 |
78 | 5. In the `url` attribute, update the version in the URL to your latest version.
79 |
80 | 6. In the `sha256` attribute, replace the existing checksum with the new checksum that you calculated.
81 |
82 | 7. Commit and push the changes.
83 |
84 |
85 | ## Packaging and distributing newdoc on Quay.io
86 |
87 | Currently, newdoc is packaged in [redhat-documentation/newdoc](https://quay.io/repository/redhat-documentation/newdoc).
88 |
89 | When you push a tagged version to the [redhat-documentation/newdoc](https://github.com/redhat-documentation/newdoc) Git repository, it automatically triggers a rebuild of the container.
90 |
91 | The version tag must start with "v" and match the `v.*` regular expression.
92 |
93 | Details on configuring the automatic build trigger: TODO.
94 |
95 |
96 | ## Packaging and distributing newdoc on Crates.io
97 |
98 | 1. If you are publishing to Crates.io for the first time on this system, log into your account:
99 |
100 | ```
101 | $ cargo login
102 | ```
103 |
104 | You can manage your login tokens in your account settings: .
105 |
106 | 2. Publish the latest version of `newdoc` to Crates.io:
107 |
108 | ```
109 | $ cargo publish
110 | ```
111 |
112 |
113 |
154 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The newdoc tool
2 |
3 | [](https://crates.io/crates/newdoc)
4 | [](https://crates.io/crates/newdoc)
5 | [](https://crates.io/crates/newdoc)
6 |
7 | [](https://github.com/redhat-documentation/newdoc/actions/workflows/rust-test.yml)
8 | [](https://deps.rs/repo/github/redhat-documentation/newdoc)
9 | [](https://copr.fedorainfracloud.org/coprs/mmuehlfeldrh/newdoc-rs/package/newdoc/)
10 |
11 | The `newdoc` tool generates pre-populated module and assembly files formatted with AsciiDoc, which are used in Red Hat and Fedora documentation. The generated files follow the Modular Documentation guidelines: .
12 |
13 | ## Using newdoc
14 |
15 | See the full documentation at [Using newdoc](https://redhat-documentation.github.io/newdoc/).
16 |
17 | ## Release notes
18 |
19 | You can find a brief change log in the [CHANGELOG.md](CHANGELOG.md) file.
20 |
--------------------------------------------------------------------------------
/build.rs:
--------------------------------------------------------------------------------
1 | //! This script auto-generates a man page from the CLI configuration.
2 |
3 | use bpaf::doc::Section;
4 | use time::OffsetDateTime;
5 |
6 | // We're reusing the module just for the Cli struct. Ignore the rest of the code
7 | // and don't report it as "never used" in this build script.
8 | #[allow(dead_code)]
9 | #[path = "src/cmd_line.rs"]
10 | mod cmd_line;
11 |
12 | // Man page metadata
13 | const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
14 | const SECTION: Section = Section::General;
15 | const CARGO_PKG_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
16 |
17 | fn main() -> std::io::Result<()> {
18 | let out_dir =
19 | std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?);
20 |
21 | let date = current_date();
22 |
23 | let parser = cmd_line::cli();
24 |
25 | let man_page = parser.render_manpage(
26 | CARGO_PKG_NAME,
27 | SECTION,
28 | Some(&date),
29 | Some(CARGO_PKG_AUTHORS),
30 | None,
31 | );
32 |
33 | let man_name = format!("{CARGO_PKG_NAME}.1");
34 | let man_path = out_dir.join(man_name);
35 |
36 | std::fs::write(man_path, man_page)?;
37 |
38 | Ok(())
39 | }
40 |
41 | /// Generate the current date to mark the last update of the man page.
42 | /// The format is "Month Year".
43 | fn current_date() -> String {
44 | let now = OffsetDateTime::now_utc();
45 | let month = now.month();
46 | let year = now.year();
47 |
48 | format!("{month} {year}")
49 | }
50 |
--------------------------------------------------------------------------------
/docs/assembly_generating-documentation-files.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 |
4 | ifdef::context[:parent-context-of-generating-documentation-files: {context}]
5 |
6 | :_mod-docs-content-type: ASSEMBLY
7 |
8 | ifndef::context[]
9 | [id="generating-documentation-files"]
10 | endif::[]
11 | ifdef::context[]
12 | [id="generating-documentation-files_{context}"]
13 | endif::[]
14 | = Generating documentation files
15 |
16 | :context: generating-documentation-files
17 |
18 | You can generate a documentation file outline that conforms to the modular templates.
19 |
20 | include::proc_creating-a-new-module.adoc[leveloffset=+1]
21 |
22 | include::proc_creating-a-new-assembly.adoc[leveloffset=+1]
23 |
24 | include::proc_creating-a-new-snippet-file.adoc[leveloffset=+1]
25 |
26 | include::proc_overwriting-existing-files.adoc[leveloffset=+1]
27 |
28 |
29 | ifdef::parent-context-of-generating-documentation-files[:context: {parent-context-of-generating-documentation-files}]
30 | ifndef::parent-context-of-generating-documentation-files[:!context:]
31 |
32 |
--------------------------------------------------------------------------------
/docs/con_configuration-files.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 |
4 | :_mod-docs-content-type: CONCEPT
5 |
6 | [id="configuration-files_{context}"]
7 | = Configuration files
8 |
9 | You can store `newdoc` configuration in several configuration files. These adjust the same behavior that you can also set using command-line options.
10 |
11 | The configuration files and arguments take the following precedence, from most important (overriding) to least important (overriden):
12 |
13 | . The command-line arguments.
14 |
15 | . A `.newdoc.toml` file in the Git repository where you generate the file.
16 | +
17 | If the Git repository is nested, `newdoc` looks for a configuration file in each repository, and the inner repository takes precedence over the outer one.
18 |
19 | . A `newdoc.toml` file in your home directory, depending on your operating system:
20 | +
21 | Linux:: `~/.config/newdoc/newdoc.toml`
22 | macOS:: `/Users/__You__/Library/Application Support/com.Red-Hat.newdoc/newdoc.toml`
23 | Windows:: `C:\Users++\++__You__\AppData\Roaming\Red Hat\newdoc\config\newdoc.toml`
24 |
25 | The configuration file has the following syntax:
26 |
27 | [source,toml]
28 | ----
29 | # These are the default values as of newdoc 2.18:
30 | comments = false
31 | examples = true
32 | metadata = true
33 | file_prefixes = true
34 | anchor_prefixes = false
35 | simplified = false
36 | ----
37 |
--------------------------------------------------------------------------------
/docs/proc_creating-a-new-assembly.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 | :_mod-docs-content-type: PROCEDURE
4 |
5 | [id="creating-a-new-assembly_{context}"]
6 | = Creating a new assembly
7 |
8 | // Write a short introductory paragraph that provides an overview of the module. The introduction should include what the module will help the user do and why it will be beneficial to the user. Include key words that relate to the module to maximize search engine optimization.
9 |
10 | // .Procedure
11 |
12 | . In the directory where assemblies are located, use `newdoc` to create a new file:
13 | +
14 | ----
15 | assemblies-dir]$ newdoc --assembly "Achieving thing"
16 | ----
17 | +
18 | You can use the short form of the `--assembly` option instead:
19 | +
20 | ----
21 | assemblies-dir]$ newdoc -a "Achieving thing"
22 | ----
23 |
24 | . Rewrite the placeholders in the generated file with your docs.
25 | +
26 | Add AsciiDoc include statements to include modules. See link:https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#include-files[Include Files] in the AsciiDoc Syntax Quick Reference.
27 | +
28 | Alternatively, you can use the `--include-in` option when creating the assembly to generate modules and include them automatically, in a single step. See the description in the *Options* section.
29 |
--------------------------------------------------------------------------------
/docs/proc_creating-a-new-module.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 | :_mod-docs-content-type: PROCEDURE
4 |
5 | [id="creating-a-new-module_{context}"]
6 | = Creating a new module
7 |
8 | // Write a short introductory paragraph that provides an overview of the module. The introduction should include what the module will help the user do and why it will be beneficial to the user. Include key words that relate to the module to maximize search engine optimization.
9 |
10 | // .Procedure
11 |
12 | . In the directory where modules are located, use `newdoc` to create a new file:
13 | +
14 | ----
15 | modules-dir]$ newdoc --procedure "Setting up thing"
16 | ----
17 | +
18 | The tool also accepts the `--concept` and `--reference` options. You can use these short forms instead: `-p`, `-c`, and `-r`.
19 |
20 | . Rewrite the placeholders in the generated file with your docs.
21 |
--------------------------------------------------------------------------------
/docs/proc_creating-a-new-snippet-file.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 | :_mod-docs-content-type: PROCEDURE
4 |
5 | [id="creating-a-new-snippet-file_{context}"]
6 | = Creating a new snippet file
7 |
8 | // Write a short introductory paragraph that provides an overview of the module. The introduction should include what the module will help the user do and why it will be beneficial to the user. Include key words that relate to the module to maximize search engine optimization.
9 |
10 | // .Procedure
11 |
12 | . In the directory where snippets are located, use `newdoc` to create a new file:
13 | +
14 | ----
15 | snippets-dir]$ newdoc --snippet "A reusable note"
16 | ----
17 | +
18 | You can use the short forms instead:
19 | +
20 | ----
21 | snippets-dir]$ newdoc -s "A reusable note"`
22 | ----
23 |
24 | . Rewrite the placeholders in the generated file with your docs.
25 |
--------------------------------------------------------------------------------
/docs/proc_installing-newdoc.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 | :_mod-docs-content-type: PROCEDURE
4 |
5 | [id="installing-newdoc_{context}"]
6 | = Installing newdoc
7 |
8 | You can install `newdoc` on various operating systems using several package managers.
9 |
10 | .Fedora, RHEL, and CentOS
11 |
12 | To install `newdoc` on current Fedora, RHEL 8 or later, or CentOS 8 or later, enable the Copr package repository:
13 |
14 | . Enable the repository:
15 | +
16 | ----
17 | # dnf copr enable mmuehlfeldrh/newdoc-rs
18 | ----
19 |
20 | . Install `newdoc`:
21 | +
22 | ----
23 | # dnf install newdoc
24 | ----
25 | +
26 | The Copr repository distributes packages only for *supported* releases of Fedora. If you have enabled the repository but the package fails to install, check if your Fedora is still supported.
27 |
28 | .openSUSE Tumbleweed
29 |
30 | To install `newdoc` on openSUSE Tumbleweed:
31 |
32 | . Enable the Copr package repository:
33 | +
34 | ----
35 | # zypper addrepo \
36 | 'https://copr.fedorainfracloud.org/coprs/mmuehlfeldrh/newdoc-rs/repo/opensuse-tumbleweed/mmuehlfeldrh-newdoc-rs-opensuse-tumbleweed.repo'
37 | ----
38 |
39 | . Install `newdoc`:
40 | +
41 | ----
42 | # zypper refresh
43 | # zypper install --allow-vendor-change newdoc
44 | ----
45 |
46 | .macOS
47 |
48 | To install `newdoc` on macOS, use the **Homebrew** package manager:
49 |
50 | . Install the **Homebrew** package manager as described on .
51 |
52 | . Add the tap (repository):
53 | +
54 | ----
55 | $ brew tap redhat-documentation/repo
56 | ----
57 |
58 | . Install `newdoc`:
59 | +
60 | ----
61 | $ brew install newdoc
62 | ----
63 |
64 | .Container
65 |
66 | To install `newdoc` as a container, use Docker or Podman.
67 |
68 | [WARNING]
69 | --
70 | The `newdoc` container needs to access files in your host file system. It mounts your current directory into the container.
71 |
72 | When the container runs, it relabels the SELinux configuration on all files in your current directory. This is necessary in order for the SELinux permissions system to enable file access on Fedora, RHEL, and CentOS.
73 |
74 | As a consequence, you cannot run the `newdoc` container in certain directories specially protected by SELinux, such as at the root of your home directory.
75 | --
76 |
77 | On Fedora, RHEL, and CentOS, replace `docker` with `podman` in the following commands:
78 |
79 | . Download the image:
80 | +
81 | ----
82 | $ docker pull quay.io/redhat-documentation/newdoc
83 | ----
84 |
85 | . Configure a command alias. Save this line in your shell configuration file, such as in the `~/.bashrc` file:
86 | +
87 | ----
88 | alias newdoc="docker run -it -v .:/mnt/newdoc:Z redhat-documentation/newdoc newdoc"
89 | ----
90 |
91 | . Open a new terminal to reload the shell configuration.
92 |
93 | . Test that `newdoc` works in a documentation directory:
94 | +
95 | ----
96 | documentation-directory]$ newdoc
97 | ----
98 |
99 | NOTE: The default `newdoc` container is based on the Alpine distribution. If you need to install packages from the RHEL ecosystem in the `newdoc` container, you can use the `quay.io/redhat-documentation/newdoc:distro` container variant. It is built on the RHEL 9 UBI Minimal base, and contains the `microdnf` package manager.
100 |
101 | .From source on any platform
102 |
103 | To install `newdoc` from source on a Linux distribution, on macOS, or on Microsoft Windows, use the `cargo` package manager:
104 |
105 | . Install the Rust toolchain: see .
106 |
107 | . Install `newdoc`:
108 | +
109 | ----
110 | $ cargo install newdoc
111 | ----
112 |
113 | . The `cargo install` command installs newdoc in the `~/.cargo/bin/` directory. To run newdoc without entering the path to the utility, add the `~/.cargo/bin/` directory to your `$PATH` variable:
114 |
115 | .. Append the following command to your `~/.bashrc` file:
116 | +
117 | ----
118 | export PATH=$PATH:$HOME/.cargo/bin/"
119 | ----
120 |
121 | .. Reload the settings from `~/.bashrc`:
122 | +
123 | ----
124 | $ source ~/.bashrc
125 | ----
126 |
127 | .Verification
128 |
129 | * Test that `newdoc` works:
130 | +
131 | ----
132 | $ newdoc
133 | ----
134 |
--------------------------------------------------------------------------------
/docs/proc_overwriting-existing-files.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 | :_mod-docs-content-type: PROCEDURE
4 |
5 | [id="overwriting-existing-files_{context}"]
6 | = Overwriting existing files
7 |
8 | When generating a new file, `newdoc` warns you if a file by that name already exists in this directory. It prompts you to choose an action.
9 |
10 | .Procedure
11 |
12 | * To overwrite the existing file with the new file, type `yes`.
13 | * To preserve the existing file and cancel the newly generated file, type `no`.
14 |
--------------------------------------------------------------------------------
/docs/proc_updating-newdoc.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 | :_mod-docs-content-type: PROCEDURE
4 |
5 | [id="updating-newdoc_{context}"]
6 | = Updating newdoc
7 |
8 | You can update `newdoc` with the package manager that you used to install it.
9 |
10 | .Fedora, RHEL, and CentOS
11 |
12 | To update `newdoc` that is installed from RPM on Fedora, RHEL, or CentOS, use the DNF package manager:
13 |
14 | . Make sure that you are using a supported release of your Linux distribution. The Copr repository does not publish `newdoc` packages for unsupported distribution releases.
15 |
16 | . Refresh repository metadata and update the package:
17 | +
18 | ----
19 | # dnf --refresh upgrade newdoc
20 | ----
21 |
22 | .openSUSE
23 |
24 | To update `newdoc` installed on openSUSE:
25 |
26 | . Make sure that you are using a supported release of your Linux distribution. The Copr repository does not publish `newdoc` packages for unsupported distribution releases.
27 |
28 | . Refresh repository metadata:
29 | +
30 | ----
31 | # zypper refresh
32 | ----
33 |
34 | . Update the package:
35 | +
36 | ----
37 | # zypper update newdoc
38 | ----
39 |
40 | .macOS
41 |
42 | To update `newdoc` installed on macOS using **Homebrew**:
43 |
44 | . Update the repository metadata:
45 | +
46 | ----
47 | $ brew update
48 | ----
49 |
50 | . Update `newdoc`:
51 | +
52 | ----
53 | $ brew upgrade newdoc
54 | ----
55 |
56 | .Container
57 |
58 | To update the `newdoc` container, use Docker or Podman.
59 |
60 | On Fedora, RHEL, and CentOS, replace `docker` with `podman` in the following command:
61 |
62 | ----
63 | $ docker pull quay.io/redhat-documentation/newdoc
64 | ----
65 |
66 | .From source on any platform
67 |
68 | To update `newdoc` from source, use the `cargo` package manager:
69 |
70 | . Update the Rust toolchain:
71 | +
72 | ----
73 | $ rustup update
74 | ----
75 |
76 | . Update `newdoc`:
77 | +
78 | ----
79 | $ cargo install newdoc
80 | ----
81 |
--------------------------------------------------------------------------------
/docs/ref_options.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: 2.18.2
2 | :_template-generated: 2024-06-05
3 |
4 | :_mod-docs-content-type: REFERENCE
5 |
6 | [id="options_{context}"]
7 | = Options
8 |
9 | You can use several options on the command line to adjust the `newdoc` behavior.
10 |
11 | .Command-line options
12 | * To generate the file with explanatory comments, add the `--comments` or `-M` option when creating documents.
13 |
14 | * To generate the file without the example, placeholder content, add the `--no-examples` or `-E` option when creating documents.
15 |
16 | * To generate the file without the metadata attributes header, add the `--no-metadata` or `-D` option when creating documents.
17 |
18 | * By default, the content type prefix appears in the generated file name and not in the ID (anchor). To change this behavior, use the following options:
19 | +
20 | `--no-file-prefixes` or `-P`:: Disables the file-name prefix.
21 | `--anchor-prefixes` or `-A`:: Enables the ID (anchor) prefix.
22 |
23 | * To specify the directory where `newdoc` saves the generated file, add the `--target-dir=` or `-T ` option.
24 |
25 | * To generate an assembly with include statements for other generated modules, use the `--include-in` or `-i` option:
26 | +
27 | ----
28 | $ newdoc --include-in "An assembly for two modules" \
29 | --concept "First module" \
30 | --procedure "Second module"
31 | ----
32 | +
33 | This creates the two modules and an assembly that features the include statements for the modules.
34 |
--------------------------------------------------------------------------------
/docs/using-newdoc.adoc:
--------------------------------------------------------------------------------
1 | :toc: left
2 |
3 | = Using newdoc
4 |
5 | The `newdoc` tool generates pre-populated module and assembly files formatted with AsciiDoc, which are used in Red Hat and Fedora documentation. The generated files follow the Modular Documentation guidelines: link:https://redhat-documentation.github.io/modular-docs/[].
6 |
7 | include::proc_installing-newdoc.adoc[leveloffset=+1]
8 |
9 | include::proc_updating-newdoc.adoc[leveloffset=+1]
10 |
11 | include::assembly_generating-documentation-files.adoc[leveloffset=+1]
12 |
13 | include::ref_options.adoc[leveloffset=+1]
14 |
15 | include::con_configuration-files.adoc[leveloffset=+1]
16 |
17 |
18 | == Additional resources
19 |
20 | * The `newdoc --help` command
21 | * link:https://github.com/redhat-documentation/newdoc[The `newdoc` Git repository]
22 | * link:https://redhat-documentation.github.io/modular-docs/[Modular Documentation Reference Guide]
23 | * link:https://redhat-documentation.github.io/asciidoc-markup-conventions/[AsciiDoc Mark-up Quick Reference for Red Hat Documentation]
24 |
--------------------------------------------------------------------------------
/newdoc.spec:
--------------------------------------------------------------------------------
1 | Name: newdoc
2 | Summary: Generate an AsciiDoc file using a modular template
3 | Version: 2.18.5
4 | Release: 1%{?dist}
5 | License: GPLv3+
6 | URL: https://github.com/redhat-documentation/newdoc
7 | Group: Applications/Text
8 | Obsoletes: python3-newdoc, python2-newdoc
9 | #Source0: https://static.crates.io/crates/%{name}/%{name}-%{version}.crate
10 | Source0: https://github.com/redhat-documentation/%{name}/archive/refs/tags/v%{version}.tar.gz
11 |
12 | # This works fine with Fedora and RHEL, but breaks the SUSE build:
13 | # ExclusiveArch: %{rust_arches}
14 |
15 | # Dependencies of the Rust compiler:
16 | BuildRequires: make
17 | BuildRequires: gcc
18 | BuildRequires: llvm
19 |
20 | %description
21 | The newdoc tool generates pre-populated module and assembly files formatted with AsciiDoc, which are used in Red Hat and Fedora documentation. The generated files follow the template guidelines maintained by the Modular Documentation initiative: https://redhat-documentation.github.io/modular-docs/.
22 |
23 | # Disable debugging packages. RPM looks for them even though none are created,
24 | # and that breaks the build if you don't set this option.
25 | %global debug_package %{nil}
26 |
27 | %prep
28 | # Unpack the sources.
29 | %setup -q
30 |
31 | %build
32 | # Install the latest Rust compiler.
33 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --component cargo
34 |
35 | # Build the binary.
36 | ~/.cargo/bin/cargo build --release
37 |
38 | %install
39 | # Clean up previous artifacts.
40 | rm -rf %{buildroot}
41 | # Prepare the target directories.
42 | install -d %{buildroot}%{_bindir}
43 | install -d %{buildroot}%{_mandir}/man1
44 | # Install the binary into the chroot environment.
45 | install -m 0755 target/release/%{name} %{buildroot}%{_bindir}/%{name}
46 | # An alternative way to install the binary using cargo.
47 | # cargo install --path . --root %{buildroot}/usr
48 | # Compress the man page
49 | gzip -c target/release/build/%{name}-*/out/%{name}.1 > %{name}.1.gz
50 | # Install the man page into the chroot environment.
51 | install -m 0644 %{name}.1.gz %{buildroot}%{_mandir}/man1/%{name}.1.gz
52 |
53 | %files
54 | # Pick documentation and license files from the source directory.
55 | %doc README.md
56 | %doc CHANGELOG.md
57 | %license LICENSE
58 | %{_mandir}/man1/%{name}.1.gz
59 | # Pick the binary from the virtual, chroot system.
60 | %{_bindir}/%{name}
61 |
--------------------------------------------------------------------------------
/src/cmd_line.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | //! # `cmd_line.rs`
20 | //!
21 | //! This module defines the command-line arguments and behavior of `newdoc`.
22 |
23 | use std::path::PathBuf;
24 |
25 | use bpaf::Bpaf;
26 | use serde::{Deserialize, Serialize};
27 |
28 | /// Generate pre-populated module files formatted with AsciiDoc that are used in Red Hat and Fedora documentation.
29 | #[derive(Clone, Debug, Bpaf)]
30 | #[bpaf(options, version)]
31 | pub struct Cli {
32 | #[bpaf(
33 | external,
34 | group_help("Generate or validate files:"),
35 | guard(at_least_one_file, SOME_FILES)
36 | )]
37 | pub action: Action,
38 |
39 | #[bpaf(external, group_help("Common options:"))]
40 | pub common_options: CommonOptions,
41 | }
42 |
43 | #[derive(Clone, Debug, Bpaf)]
44 | pub struct CommonOptions {
45 | /// Save the generated files in this directory
46 | #[bpaf(short('T'), long, argument("DIRECTORY"), fallback(".".into()))]
47 | pub target_dir: PathBuf,
48 |
49 | #[bpaf(external, optional)]
50 | pub comments: Option,
51 |
52 | #[bpaf(external, optional)]
53 | pub examples: Option,
54 |
55 | #[bpaf(external, optional)]
56 | pub metadata: Option,
57 |
58 | #[bpaf(external, optional)]
59 | pub file_prefixes: Option,
60 |
61 | #[bpaf(external, optional)]
62 | pub anchor_prefixes: Option,
63 |
64 | #[bpaf(external, optional)]
65 | pub simplified: Option,
66 |
67 | #[bpaf(external, fallback(Verbosity::default()))]
68 | pub verbosity: Verbosity,
69 | }
70 |
71 | #[derive(Clone, Debug, Bpaf)]
72 | pub struct Action {
73 | /// Create an assembly file
74 | #[bpaf(short, long, argument("TITLE"))]
75 | pub assembly: Vec,
76 |
77 | /// Create a concept module
78 | #[bpaf(short, long, argument("TITLE"))]
79 | pub concept: Vec,
80 |
81 | /// Create a procedure module
82 | #[bpaf(short, long, argument("TITLE"))]
83 | pub procedure: Vec,
84 |
85 | /// Create a reference module
86 | #[bpaf(short, long, argument("TITLE"))]
87 | pub reference: Vec,
88 |
89 | /// Create a snippet file
90 | #[bpaf(short, long, argument("TITLE"))]
91 | pub snippet: Vec,
92 |
93 | /// Create an assembly that includes the other specified modules
94 | #[bpaf(short, long, argument("TITLE"))]
95 | pub include_in: Option,
96 |
97 | /// REMOVED: Validate (lint) an existing module or assembly file
98 | /// The option is hidden, has no effect, and exists only for compatibility
99 | /// with previous releases.
100 | #[bpaf(short('l'), long, argument("FILE"), hide)]
101 | pub validate: Vec,
102 | }
103 |
104 | /// The verbosity level set on the command line.
105 | /// The default option is invisible as a command-line argument.
106 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq, Serialize, Deserialize)]
107 | #[serde(rename_all = "lowercase")]
108 | pub enum Verbosity {
109 | /// Display additional, debug messages
110 | #[bpaf(short, long)]
111 | Verbose,
112 | /// Hide info-level messages. Display only warnings and errors
113 | #[bpaf(short, long)]
114 | Quiet,
115 | #[default]
116 | #[bpaf(hide)]
117 | Default,
118 | }
119 |
120 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
121 | pub enum Comments {
122 | /// Generate the file without any comments. (Default)
123 | #[default]
124 | #[bpaf(short('C'), long)]
125 | NoComments,
126 | /// Generate the file with explanatory comments
127 | #[bpaf(short('M'), long)]
128 | Comments,
129 | }
130 |
131 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
132 | pub enum Examples {
133 | /// Generate the file with the example, placeholder content. (Default)
134 | #[default]
135 | #[bpaf(long)]
136 | Examples,
137 | /// Generate the file without any example, placeholder content.
138 | #[bpaf(short('E'), long, long("expert-mode"))]
139 | NoExamples,
140 | }
141 |
142 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
143 | pub enum Simplified {
144 | /// Generate the file without conditionals for the Red Hat documentation pipeline. Suitable for upstream.
145 | #[bpaf(short('S'), long)]
146 | Simplified,
147 | /// Generate the file with conditionals for the Red Hat documentation pipeline. (Default)
148 | #[default]
149 | #[bpaf(long)]
150 | NotSimplified,
151 | }
152 |
153 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
154 | pub enum Metadata {
155 | /// Generate the file with the metadata attributes header. (Default)
156 | #[default]
157 | #[bpaf(long)]
158 | Metadata,
159 | /// Generate the file without any example, placeholder content.
160 | #[bpaf(long, short('D'))]
161 | NoMetadata,
162 | }
163 |
164 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
165 | pub enum FilePrefixes {
166 | /// Use module type prefixes (such as `proc_`) in file names. (Default)
167 | #[default]
168 | #[bpaf(long)]
169 | FilePrefixes,
170 | /// Do not use module type prefixes (such as `proc_`) in file names.
171 | #[bpaf(short('P'), long, long("no-prefixes"))]
172 | NoFilePrefixes,
173 | }
174 |
175 | #[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
176 | pub enum AnchorPrefixes {
177 | /// Add module type prefixes (such as `proc_`) in AsciiDoc anchors.
178 | #[bpaf(short('A'), long)]
179 | AnchorPrefixes,
180 | /// Do not add module type prefixes (such as `proc_`) in AsciiDoc anchors. (Default)
181 | #[default]
182 | #[bpaf(long)]
183 | NoAnchorPrefixes,
184 | }
185 |
186 | /// Check that the current command generates or validates at least one file.
187 | fn at_least_one_file(action: &Action) -> bool {
188 | !action.assembly.is_empty()
189 | || !action.concept.is_empty()
190 | || !action.procedure.is_empty()
191 | || !action.reference.is_empty()
192 | || !action.snippet.is_empty()
193 | || !action.validate.is_empty()
194 | || action.include_in.is_some()
195 | }
196 |
197 | /// The error message if the command does not generate or validate files.
198 | const SOME_FILES: &str = "Specify at least one file to generate.";
199 |
200 | /// Get command-line arguments as the `Cli` struct.
201 | #[must_use]
202 | pub fn get_args() -> Cli {
203 | cli().run()
204 | }
205 |
--------------------------------------------------------------------------------
/src/config.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2024 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | //! # `config.rs`
20 | //!
21 | //! This module defines the global options merged from the command line,
22 | //! the configuration files, and the defaults.
23 |
24 | use std::path::{Path, PathBuf};
25 |
26 | use color_eyre::eyre::{Result, WrapErr};
27 | use directories::ProjectDirs;
28 | use figment::{
29 | providers::{Format, Serialized, Toml},
30 | Figment,
31 | };
32 | use serde::{Deserialize, Serialize};
33 |
34 | use crate::cmd_line::{
35 | AnchorPrefixes, Cli, Comments, Examples, FilePrefixes, Metadata, Simplified, Verbosity,
36 | };
37 |
38 | const PKG_NAME: &str = env!("CARGO_PKG_NAME");
39 |
40 | /// This struct stores options based on the command-line arguments,
41 | /// and is passed to various functions across the program.
42 | #[derive(Debug, Clone, Serialize, Deserialize)]
43 | pub struct Options {
44 | pub comments: bool,
45 | pub file_prefixes: bool,
46 | pub anchor_prefixes: bool,
47 | pub examples: bool,
48 | pub metadata: bool,
49 | pub target_dir: PathBuf,
50 | pub simplified: bool,
51 | pub verbosity: Verbosity,
52 | }
53 |
54 | impl Options {
55 | /// Update the values in this instance from the command line, but only in cases
56 | /// where the command line's values are specified.
57 | /// Where the command line options are missing, preserve the value in self.
58 | fn update_from_cli(&mut self, cli: &Cli) {
59 | // This code is kinda ugly and could be solved by figment merging:
60 | // https://steezeburger.com/2023/03/rust-hierarchical-configuration/
61 | // However, given how few options there are and how special the figment
62 | // solution is, I prefer this more explicit approach that gives manual control.
63 |
64 | // Update the manually specified values:
65 | match cli.common_options.comments {
66 | Some(Comments::Comments) => {
67 | self.comments = true;
68 | }
69 | Some(Comments::NoComments) => {
70 | self.comments = false;
71 | }
72 | None => { /* Keep the existing value. */ }
73 | }
74 | match cli.common_options.file_prefixes {
75 | Some(FilePrefixes::FilePrefixes) => {
76 | self.file_prefixes = true;
77 | }
78 | Some(FilePrefixes::NoFilePrefixes) => {
79 | self.file_prefixes = false;
80 | }
81 | None => { /* Keep the existing value. */ }
82 | }
83 | match cli.common_options.anchor_prefixes {
84 | Some(AnchorPrefixes::AnchorPrefixes) => {
85 | self.anchor_prefixes = true;
86 | }
87 | Some(AnchorPrefixes::NoAnchorPrefixes) => {
88 | self.anchor_prefixes = false;
89 | }
90 | None => { /* Keep the existing value. */ }
91 | }
92 | match cli.common_options.examples {
93 | Some(Examples::Examples) => {
94 | self.examples = true;
95 | }
96 | Some(Examples::NoExamples) => {
97 | self.examples = false;
98 | }
99 | None => { /* Keep the existing value. */ }
100 | }
101 | match cli.common_options.metadata {
102 | Some(Metadata::Metadata) => {
103 | self.metadata = true;
104 | }
105 | Some(Metadata::NoMetadata) => {
106 | self.metadata = false;
107 | }
108 | None => { /* Keep the existing value. */ }
109 | }
110 | match cli.common_options.simplified {
111 | Some(Simplified::Simplified) => {
112 | self.simplified = true;
113 | }
114 | Some(Simplified::NotSimplified) => {
115 | self.simplified = false;
116 | }
117 | None => { /* Keep the existing value. */ }
118 | }
119 | // TODO: Because the verbosity field isn't optional on the CLI, but rather
120 | // defaults to the `Default` value, the CLI always overrides the config files,
121 | // even though the config files recognize the option in theory.
122 | // Consider if it's useful to configure verbosity, and if so,
123 | // change the behavior so that the config files have effect.
124 | match cli.common_options.verbosity {
125 | Verbosity::Verbose => {
126 | self.verbosity = Verbosity::Verbose;
127 | }
128 | Verbosity::Quiet => {
129 | self.verbosity = Verbosity::Quiet;
130 | }
131 | Verbosity::Default => { /* Keep the existing value. */ }
132 | }
133 |
134 | // These options only exist on the command line, not in config files.
135 | // Always use the value from CLI arguments.
136 | self.target_dir.clone_from(&cli.common_options.target_dir);
137 | }
138 | }
139 |
140 | impl Default for Options {
141 | /// This is the canonical source of default runtime options.
142 | fn default() -> Self {
143 | Self {
144 | comments: false,
145 | file_prefixes: true,
146 | anchor_prefixes: false,
147 | examples: true,
148 | simplified: false,
149 | metadata: true,
150 | verbosity: Verbosity::Default,
151 | target_dir: ".".into(),
152 | }
153 | }
154 | }
155 |
156 | /// Provides the base name of the configuration file:
157 | /// The `hidden` option controls whether this is a hidden file
158 | /// with a dot at the start, such as `.newdoc.toml`, or
159 | /// a regular, visible file, such as `newdoc.toml`.
160 | fn config_file_name(hidden: bool) -> String {
161 | let prefix = if hidden { "." } else { "" };
162 | format!("{prefix}{PKG_NAME}.toml")
163 | }
164 |
165 | /// Try to locale the appropriate per-user configuration file on this platform.
166 | fn home_conf_file() -> Option {
167 | let proj_dirs = ProjectDirs::from("com", "Red Hat", PKG_NAME)?;
168 | let conf_dir = proj_dirs.config_dir();
169 | let conf_file = conf_dir.join(config_file_name(false));
170 |
171 | Some(conf_file)
172 | }
173 |
174 | /// If the target location is in a Git repository, construct the path
175 | /// to a configuration file at the repository's root.
176 | /// Find all such configuration files if the Git repository is nested.
177 | fn git_conf_files(target_dir: &Path) -> Result> {
178 | let absolute_path = target_dir
179 | .canonicalize()
180 | .wrap_err("Failed to construct the absolute path to the target directory.")?;
181 | // Find all ancestor directories that appear to be the root of a Git repo.
182 | let git_roots = absolute_path.ancestors().filter(|dir| {
183 | // The simple heuristic is that the directory is the Git root if it contains
184 | // the `.git/` sub-directory.
185 | let git_dir = dir.join(".git");
186 | log::debug!(
187 | "Testing this directory as a Git repo root: {}",
188 | git_dir.display()
189 | );
190 | git_dir.is_dir()
191 | });
192 |
193 | let config_files: Vec<_> = git_roots
194 | .map(|root| {
195 | log::debug!("Found a Git repo root: {}", root.display());
196 | root.join(config_file_name(true))
197 | })
198 | .collect();
199 |
200 | Ok(config_files)
201 | }
202 |
203 | /// Combine the configuration found on the command line, in configuration files,
204 | /// and in the defaults. Follows the standard hierarchy.
205 | pub fn merge_configs(cli: &Cli) -> Result {
206 | // The default options are the base for further merging.
207 | let default_options = Options::default();
208 |
209 | // Prepare a figment instance to load config files.
210 | let mut figment = Figment::from(Serialized::defaults(default_options));
211 |
212 | // Load the home configuration file, if it exists:
213 | if let Some(home_conf_file) = home_conf_file() {
214 | log::debug!("Home configuration file: {}", home_conf_file.display());
215 | figment = figment.merge(Toml::file(home_conf_file));
216 | } else {
217 | // If the directory lookup fails because there's no home directory,
218 | // skip the processing of the home configuration file.
219 | log::warn!("Failed to locate a home directory. Skipping home configuration.");
220 | };
221 |
222 | // All config files in Git repo roots:
223 | let mut git_conf_files = git_conf_files(&cli.common_options.target_dir)?;
224 | // Reverse their order so that the inner repo configuration takes precedence over outer:
225 | git_conf_files.reverse();
226 | // Load each Git repo configuration file:
227 | for file in git_conf_files {
228 | log::info!("Git repo configuration file: {}", file.display());
229 | figment = figment.merge(Toml::file(file));
230 | }
231 |
232 | log::debug!("Figment configuration: {figment:#?}");
233 |
234 | let mut conf_options: Options = figment
235 | .extract()
236 | .wrap_err("Failed to load configuration files.")?;
237 |
238 | conf_options.update_from_cli(cli);
239 |
240 | Ok(conf_options)
241 | }
242 |
--------------------------------------------------------------------------------
/src/lib.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | // Enable additional clippy lints by default.
20 | #![warn(
21 | clippy::pedantic,
22 | clippy::unwrap_used,
23 | clippy::clone_on_ref_ptr,
24 | clippy::todo
25 | )]
26 | // Disable the documentation clippy lint, so that it stops suggesting backticks around AsciiDoc.
27 | #![allow(clippy::doc_markdown)]
28 | // Forbid unsafe code in this program.
29 | #![forbid(unsafe_code)]
30 |
31 | //! # newdoc
32 | //! The `newdoc` tool generates pre-populated module and assembly files formatted with AsciiDoc,
33 | //! which are used in Red Hat and Fedora documentation. The generated files follow
34 | //! the Modular Documentation guidelines: .
35 |
36 | use color_eyre::eyre::{bail, Result};
37 |
38 | pub mod cmd_line;
39 | pub mod config;
40 | pub mod logging;
41 | mod module;
42 | mod templating;
43 | mod write;
44 |
45 | use cmd_line::{Cli, Verbosity};
46 | pub use config::Options;
47 | pub use module::{ContentType, Input, Module};
48 |
49 | /// newdoc uses many regular expressions at several places. Constructing them should never fail,
50 | /// because the pattern doesn't change at runtime, but in case it does, present a unified
51 | /// error message through `expect`.
52 | const REGEX_ERROR: &str = "Failed to construct a regular expression. Please report this as a bug";
53 |
54 | pub fn run(options: &Options, cli: &Cli) -> Result<()> {
55 | log::debug!("Active options:\n{:#?}", &options);
56 |
57 | // Report any deprecated options.
58 | if !cli.action.validate.is_empty() {
59 | log::warn!("The validation feature has been removed. \
60 | Please switch to the Enki validation tool: .");
61 | }
62 |
63 | // Attach titles from the CLI to content types.
64 | let content_types = [
65 | (ContentType::Assembly, &cli.action.assembly),
66 | (ContentType::Concept, &cli.action.concept),
67 | (ContentType::Procedure, &cli.action.procedure),
68 | (ContentType::Reference, &cli.action.reference),
69 | (ContentType::Snippet, &cli.action.snippet),
70 | ];
71 |
72 | // Store all modules except for the populated assembly that will be created in this Vec
73 | let mut non_populated: Vec = Vec::new();
74 |
75 | // For each module type, see if it occurs on the command line and process it
76 | for (content_type, titles) in content_types {
77 | // Check if the given module type occurs on the command line
78 | let mut modules = process_module_type(titles, content_type, options);
79 |
80 | // Move all the newly created modules into the common Vec
81 | non_populated.append(&mut modules);
82 | }
83 |
84 | // Write all non-populated modules to the disk
85 | for module in &non_populated {
86 | module.write_file(options)?;
87 | }
88 |
89 | // Treat the populated assembly module as a special case:
90 | // * There can be only one populated assembly
91 | // * It must be generated after the other modules so that it can use their include statements
92 | if let Some(title) = &cli.action.include_in {
93 | // Gather all include statements for the other modules
94 | let include_statements: Vec = non_populated
95 | .into_iter()
96 | .map(|module| module.include_statement)
97 | .collect();
98 |
99 | // The include_statements should never be empty thanks to the required group in clap.
100 | // Make sure once more, though.
101 | if include_statements.is_empty() {
102 | bail!("The populated assembly includes no other files.");
103 | }
104 |
105 | // Generate the populated assembly module
106 | let populated: Module = Input::new(ContentType::Assembly, title, options)
107 | .include(include_statements)
108 | .into();
109 |
110 | populated.write_file(options)?;
111 | }
112 |
113 | Ok(())
114 | }
115 |
116 | /// Process all titles that have been specified on the command line and that belong to a single
117 | /// module type.
118 | fn process_module_type(
119 | titles: &[String],
120 | content_type: ContentType,
121 | options: &Options,
122 | ) -> Vec {
123 | let modules_from_type = titles
124 | .iter()
125 | .map(|title| Module::new(content_type, title, options));
126 |
127 | modules_from_type.collect()
128 | }
129 |
--------------------------------------------------------------------------------
/src/logging.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | use color_eyre::eyre::{Context, Result};
20 | use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
21 |
22 | use crate::Verbosity;
23 |
24 | /// This function initializes the `simplelog` logging system, which plugs into the `log`
25 | /// infrastructure. The function returns nothing. It only affects the global state when it runs.
26 | pub fn initialize_logger(verbosity: Verbosity) -> Result<()> {
27 | // Set the verbosity level based on the command-line options.
28 | // Our `clap` configuration ensures that `verbose` and `quiet` can never be both true.
29 | let verbosity = match verbosity {
30 | Verbosity::Verbose => LevelFilter::Debug,
31 | Verbosity::Quiet => LevelFilter::Warn,
32 | // The default verbosity level is Info because newdoc displays the include statement
33 | // at that level.
34 | Verbosity::Default => LevelFilter::Info,
35 | };
36 |
37 | let config = ConfigBuilder::new()
38 | // Display a time stamp only for the most verbose level.
39 | .set_time_level(LevelFilter::Trace)
40 | // Display the thread number only for the most verbose level.
41 | // The information is hardly useful because newdoc is single-threaded.
42 | .set_thread_level(LevelFilter::Trace)
43 | .build();
44 |
45 | TermLogger::init(
46 | verbosity,
47 | config,
48 | // Mixed mode prints errors to stderr and info to stdout. Not sure about the other levels.
49 | TerminalMode::Mixed,
50 | // Try to use color if possible.
51 | ColorChoice::Auto,
52 | )
53 | .context("Failed to configure the terminal logging.")?;
54 |
55 | Ok(())
56 | }
57 |
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | use color_eyre::eyre::Result;
20 |
21 | use newdoc::{cmd_line, config, logging};
22 |
23 | fn main() -> Result<()> {
24 | // Enable full-featured error logging.
25 | color_eyre::install()?;
26 |
27 | // Parse the command-line options
28 | let cmdline_args = cmd_line::get_args();
29 |
30 | // Initialize the logging system based on the set verbosity
31 | logging::initialize_logger(cmdline_args.common_options.verbosity)?;
32 |
33 | // Set current options based on the command-line options and config files.
34 | let options = config::merge_configs(&cmdline_args)?;
35 |
36 | // Run the main functionality
37 | newdoc::run(&options, &cmdline_args)?;
38 |
39 | Ok(())
40 | }
41 |
--------------------------------------------------------------------------------
/src/module.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | //! This module defines the `Module` struct, its builder struct, and methods on both structs.
20 |
21 | use std::fmt;
22 | use std::path::{Component, Path, PathBuf};
23 |
24 | use crate::Options;
25 |
26 | /// All possible types of the AsciiDoc module
27 | #[derive(Debug, Clone, Copy, PartialEq, Eq)]
28 | pub enum ContentType {
29 | Assembly,
30 | Concept,
31 | Procedure,
32 | Reference,
33 | Snippet,
34 | }
35 |
36 | // Implement human-readable string display for the module type
37 | impl fmt::Display for ContentType {
38 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39 | let name = match self {
40 | Self::Assembly => "assembly",
41 | Self::Concept => "concept",
42 | Self::Procedure => "procedure",
43 | Self::Reference => "reference",
44 | Self::Snippet => "snippet",
45 | };
46 | write!(f, "{name}")
47 | }
48 | }
49 |
50 | /// An initial representation of the module with input data, used to construct the `Module` struct
51 | #[derive(Debug)]
52 | pub struct Input {
53 | pub mod_type: ContentType,
54 | pub title: String,
55 | pub options: Options,
56 | pub includes: Option>,
57 | }
58 |
59 | /// A representation of the module with all its metadata and the generated AsciiDoc content
60 | #[derive(Debug, PartialEq, Eq)]
61 | pub struct Module {
62 | mod_type: ContentType,
63 | title: String,
64 | anchor: String,
65 | pub file_name: String,
66 | pub include_statement: String,
67 | includes: Option>,
68 | pub text: String,
69 | }
70 |
71 | /// Construct a basic builder for `Module`, storing information from the user input.
72 | impl Input {
73 | #[must_use]
74 | pub fn new(mod_type: ContentType, title: &str, options: &Options) -> Input {
75 | log::debug!("Processing title `{}` of type `{:?}`", title, mod_type);
76 |
77 | let title = String::from(title);
78 | let options = options.clone();
79 |
80 | Input {
81 | mod_type,
82 | title,
83 | options,
84 | includes: None,
85 | }
86 | }
87 |
88 | /// Set the optional include statements for files that this assembly includes
89 | #[must_use]
90 | pub fn include(mut self, include_statements: Vec) -> Self {
91 | self.includes = Some(include_statements);
92 | self
93 | }
94 |
95 | /// Create an ID string that is derived from the human-readable title. The ID is usable as:
96 | ///
97 | /// * An AsciiDoc section ID
98 | /// * A DocBook section ID
99 | /// * A file name
100 | ///
101 | /// # Examples
102 | ///
103 | /// ```
104 | /// use newdoc::{ContentType, Input, Options};
105 | ///
106 | /// let mod_type = ContentType::Concept;
107 | /// let title = "A test -- with #problematic ? characters";
108 | /// let options = Options::default();
109 | /// let input = Input::new(mod_type, title, &options);
110 | ///
111 | /// assert_eq!("a-test-with-problematic-characters", input.id());
112 | /// ```
113 | #[must_use]
114 | pub fn id(&self) -> String {
115 | let title = &self.title;
116 | // The ID is all lower-case
117 | let mut title_with_replacements: String = String::from(title).to_lowercase();
118 |
119 | // Replace characters that aren't allowed in the ID, usually with a dash or an empty string
120 | let substitutions = [
121 | (" ", "-"),
122 | ("(", ""),
123 | (")", ""),
124 | ("?", ""),
125 | ("!", ""),
126 | ("'", ""),
127 | ("\"", ""),
128 | ("#", ""),
129 | ("%", ""),
130 | ("&", ""),
131 | ("*", ""),
132 | (",", "-"),
133 | (".", "-"),
134 | ("/", "-"),
135 | (":", "-"),
136 | (";", ""),
137 | ("@", "-at-"),
138 | ("\\", ""),
139 | ("`", ""),
140 | ("$", ""),
141 | ("^", ""),
142 | ("|", ""),
143 | ("=", "-"),
144 | // Remove known semantic markup from the ID:
145 | ("[package]", ""),
146 | ("[option]", ""),
147 | ("[parameter]", ""),
148 | ("[variable]", ""),
149 | ("[command]", ""),
150 | ("[replaceable]", ""),
151 | ("[filename]", ""),
152 | ("[literal]", ""),
153 | ("[systemitem]", ""),
154 | ("[application]", ""),
155 | ("[function]", ""),
156 | ("[gui]", ""),
157 | // Remove square brackets only after semantic markup:
158 | ("[", ""),
159 | ("]", ""),
160 | // TODO: Curly braces shouldn't appear in the title in the first place.
161 | // They'd be interpreted as attributes there.
162 | // Print an error in that case? Escape them with AsciiDoc escapes?
163 | ("{", ""),
164 | ("}", ""),
165 | ];
166 |
167 | // Perform all the defined replacements on the title
168 | for (old, new) in substitutions {
169 | title_with_replacements = title_with_replacements.replace(old, new);
170 | }
171 |
172 | // Replace remaining characters that aren't ASCII, or that are non-alphanumeric ASCII,
173 | // with dashes. For example, this replaces diacritics and typographic quotation marks.
174 | title_with_replacements = title_with_replacements
175 | .chars()
176 | .map(|c| if c.is_ascii_alphanumeric() { c } else { '-' })
177 | .collect();
178 |
179 | // Ensure the converted ID doesn't contain double dashes ("--"), because
180 | // that breaks references to the ID
181 | while title_with_replacements.contains("--") {
182 | title_with_replacements = title_with_replacements.replace("--", "-");
183 | }
184 |
185 | // Ensure that the ID doesn't end with a dash
186 | if title_with_replacements.ends_with('-') {
187 | let len = title_with_replacements.len();
188 | title_with_replacements = title_with_replacements[..len - 1].to_string();
189 | }
190 |
191 | title_with_replacements
192 | }
193 |
194 | /// Prepare the file name for the generated file.
195 | ///
196 | /// The file name is based on the module ID,
197 | /// with an optional prefix and the `.adoc` extension.
198 | ///
199 | /// # Examples
200 | ///
201 | /// ```
202 | /// use newdoc::{ContentType, Input, Options};
203 | ///
204 | /// let mod_type = ContentType::Concept;
205 | /// let title = "Default file name configuration";
206 | /// let options = Options::default();
207 | /// let input = Input::new(mod_type, title, &options);
208 | ///
209 | /// assert_eq!("con_default-file-name-configuration.adoc", input.file_name());
210 | ///
211 | /// let mod_type = ContentType::Concept;
212 | /// let title = "No prefix file name configuration";
213 | /// let options = Options {
214 | /// file_prefixes: false,
215 | /// ..Default::default()
216 | /// };
217 | /// let input = Input::new(mod_type, title, &options);
218 | ///
219 | /// assert_eq!("no-prefix-file-name-configuration.adoc", input.file_name());
220 | /// ```
221 | #[must_use]
222 | pub fn file_name(&self) -> String {
223 | // Add a prefix only if they're enabled.
224 | let prefix = if self.options.file_prefixes {
225 | self.prefix()
226 | } else {
227 | ""
228 | };
229 |
230 | let id = self.id();
231 |
232 | let suffix = ".adoc";
233 |
234 | [prefix, &id, suffix].join("")
235 | }
236 |
237 | /// Prepare the AsciiDoc anchor or ID.
238 | ///
239 | /// The anchor is based on the module ID, with an optional prefix.
240 | ///
241 | /// # Examples
242 | ///
243 | /// ```
244 | /// use newdoc::{ContentType, Input, Options};
245 | ///
246 | /// let mod_type = ContentType::Concept;
247 | /// let title = "Default anchor configuration";
248 | /// let options = Options::default();
249 | /// let input = Input::new(mod_type, title, &options);
250 | ///
251 | /// assert_eq!("default-anchor-configuration", input.anchor());
252 | ///
253 | /// let mod_type = ContentType::Concept;
254 | /// let title = "Prefix anchor configuration";
255 | /// let options = Options {
256 | /// anchor_prefixes: true,
257 | /// ..Default::default()
258 | /// };
259 | /// let input = Input::new(mod_type, title, &options);
260 | ///
261 | /// assert_eq!("con_prefix-anchor-configuration", input.anchor());
262 | #[must_use]
263 | pub fn anchor(&self) -> String {
264 | // Add a prefix only if they're enabled.
265 | let prefix = if self.options.anchor_prefixes {
266 | self.prefix()
267 | } else {
268 | ""
269 | };
270 |
271 | let id = self.id();
272 |
273 | [prefix, &id].join("")
274 | }
275 |
276 | /// Pick the right file and ID prefix depending on the content type.
277 | fn prefix(&self) -> &'static str {
278 | match self.mod_type {
279 | ContentType::Assembly => "assembly_",
280 | ContentType::Concept => "con_",
281 | ContentType::Procedure => "proc_",
282 | ContentType::Reference => "ref_",
283 | ContentType::Snippet => "snip_",
284 | }
285 | }
286 |
287 | /// Prepare an include statement that can be used to include the generated file from elsewhere.
288 | fn include_statement(&self) -> String {
289 | let path_placeholder = Path::new("").to_path_buf();
290 |
291 | let include_path = match self.infer_include_dir() {
292 | Some(path) => path,
293 | None => path_placeholder,
294 | };
295 |
296 | format!(
297 | "include::{}/{}[leveloffset=+1]",
298 | include_path.display(),
299 | &self.file_name()
300 | )
301 | }
302 |
303 | /// Determine the start of the include statement from the target path.
304 | /// Returns the relative path that can be used in the include statement, if it's possible
305 | /// to determine it automatically.
306 | fn infer_include_dir(&self) -> Option {
307 | // The first directory in the include path is either `assemblies/` or `modules/`,
308 | // based on the module type, or `snippets/` for snippet files.
309 | let include_root = match &self.mod_type {
310 | ContentType::Assembly => "assemblies",
311 | ContentType::Snippet => "snippets",
312 | _ => "modules",
313 | };
314 |
315 | // TODO: Maybe convert the path earlier in the module building.
316 | let relative_path = Path::new(&self.options.target_dir);
317 | // Try to find the root element in an absolute path.
318 | // If the absolute path cannot be constructed due to an error, search the relative path instead.
319 | let target_path = match relative_path.canonicalize() {
320 | Ok(path) => path,
321 | Err(_) => relative_path.to_path_buf(),
322 | };
323 |
324 | // Split the target path into components
325 | let component_vec: Vec<_> = target_path
326 | .as_path()
327 | .components()
328 | .map(Component::as_os_str)
329 | .collect();
330 |
331 | // Find the position of the component that matches the root element,
332 | // searching from the end of the path forward.
333 | let root_position = component_vec.iter().rposition(|&c| c == include_root);
334 |
335 | // If there is such a root element in the path, construct the include path.
336 | // TODO: To be safe, check that the root path element still exists in a Git repository.
337 | if let Some(position) = root_position {
338 | let include_path = component_vec[position..].iter().collect::();
339 | Some(include_path)
340 | // If no appropriate root element was found, use a generic placeholder.
341 | } else {
342 | None
343 | }
344 | }
345 | }
346 |
347 | impl From for Module {
348 | /// Convert the `Input` builder struct into the finished `Module` struct.
349 | fn from(input: Input) -> Self {
350 | let module = Module {
351 | mod_type: input.mod_type,
352 | title: input.title.clone(),
353 | anchor: input.anchor(),
354 | file_name: input.file_name(),
355 | include_statement: input.include_statement(),
356 | includes: input.includes.clone(),
357 | text: input.text(),
358 | };
359 |
360 | log::debug!("Generated module properties:");
361 | log::debug!("Type: {:?}", &module.mod_type);
362 | log::debug!("Anchor: {}", &module.anchor);
363 | log::debug!("File name: {}", &module.file_name);
364 | log::debug!("Include statement: {}", &module.include_statement);
365 | log::debug!(
366 | "Included modules: {}",
367 | if let Some(includes) = &module.includes {
368 | includes.join(", ")
369 | } else {
370 | "none".to_string()
371 | }
372 | );
373 |
374 | module
375 | }
376 | }
377 |
378 | impl Module {
379 | /// The constructor for the Module struct. Creates a basic version of Module
380 | /// without any optional features.
381 | #[must_use]
382 | pub fn new(mod_type: ContentType, title: &str, options: &Options) -> Module {
383 | let input = Input::new(mod_type, title, options);
384 | input.into()
385 | }
386 | }
387 |
388 | #[cfg(test)]
389 | mod tests {
390 | use super::*;
391 | use crate::{Options, Verbosity};
392 |
393 | fn basic_options() -> Options {
394 | Options {
395 | comments: false,
396 | file_prefixes: true,
397 | anchor_prefixes: false,
398 | examples: true,
399 | target_dir: PathBuf::from("."),
400 | verbosity: Verbosity::Default,
401 | ..Default::default()
402 | }
403 | }
404 |
405 | fn path_options() -> Options {
406 | Options {
407 | comments: false,
408 | file_prefixes: true,
409 | anchor_prefixes: false,
410 | examples: true,
411 | target_dir: PathBuf::from("repo/modules/topic/"),
412 | verbosity: Verbosity::Default,
413 | ..Default::default()
414 | }
415 | }
416 |
417 | #[test]
418 | fn check_basic_assembly_fields() {
419 | let options = basic_options();
420 | let assembly = Module::new(
421 | ContentType::Assembly,
422 | "A testing assembly with /special-characters*",
423 | &options,
424 | );
425 |
426 | assert_eq!(assembly.mod_type, ContentType::Assembly);
427 | assert_eq!(
428 | assembly.title,
429 | "A testing assembly with /special-characters*"
430 | );
431 | assert_eq!(
432 | assembly.anchor,
433 | "a-testing-assembly-with-special-characters"
434 | );
435 | assert_eq!(
436 | assembly.file_name,
437 | "assembly_a-testing-assembly-with-special-characters.adoc"
438 | );
439 | assert_eq!(assembly.include_statement, "include::/assembly_a-testing-assembly-with-special-characters.adoc[leveloffset=+1]");
440 | assert_eq!(assembly.includes, None);
441 | }
442 |
443 | #[test]
444 | fn check_module_builder_and_new() {
445 | let options = basic_options();
446 | let from_new: Module = Module::new(
447 | ContentType::Assembly,
448 | "A testing assembly with /special-characters*",
449 | &options,
450 | );
451 | let from_builder: Module = Input::new(
452 | ContentType::Assembly,
453 | "A testing assembly with /special-characters*",
454 | &options,
455 | )
456 | .into();
457 | assert_eq!(from_new, from_builder);
458 | }
459 |
460 | #[test]
461 | fn check_detected_path() {
462 | let options = path_options();
463 |
464 | let module = Module::new(
465 | ContentType::Procedure,
466 | "Testing the detected path",
467 | &options,
468 | );
469 |
470 | assert_eq!(
471 | module.include_statement,
472 | "include::modules/topic/proc_testing-the-detected-path.adoc[leveloffset=+1]"
473 | );
474 | }
475 | }
476 |
--------------------------------------------------------------------------------
/src/templating.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | use askama::Template;
20 | use regex::{Regex, RegexBuilder};
21 | use time::OffsetDateTime;
22 |
23 | use crate::module::{ContentType, Input};
24 | use crate::REGEX_ERROR;
25 |
26 | // A note on the structure of this file:
27 | // This file repeats a lot of code when it configures the Askama templates.
28 | // Either we could fix it by using a generics trick, which I haven't learned yet,
29 | // or the repetition is inherent to the way the templates share some properties, but only
30 | // by accident, not as a rule.
31 | // For now, the code works as intended, and the file is short enough that I'm not bothered
32 | // to see the questionable esthetics.
33 |
34 | // Specify a template in terms of the Askama engine
35 | #[derive(Template)]
36 | // Askama loads the template files from the `data/templates` directory,
37 | // which is configured in the `askama.toml` file.
38 | #[template(path = "assembly.adoc", escape = "none")]
39 | struct AssemblyTemplate<'a> {
40 | // The field name must match the variable name in the template
41 | module_anchor: &'a str,
42 | module_title: &'a str,
43 | include_statements: &'a str,
44 | examples: bool,
45 | metadata: bool,
46 | generator_version: &'a str,
47 | current_day: &'a str,
48 | simplified: bool,
49 | }
50 |
51 | #[derive(Template)]
52 | #[template(path = "concept.adoc", escape = "none")]
53 | struct ConceptTemplate<'a> {
54 | module_anchor: &'a str,
55 | module_title: &'a str,
56 | examples: bool,
57 | metadata: bool,
58 | generator_version: &'a str,
59 | current_day: &'a str,
60 | simplified: bool,
61 | }
62 |
63 | #[derive(Template)]
64 | #[template(path = "procedure.adoc", escape = "none")]
65 | struct ProcedureTemplate<'a> {
66 | module_anchor: &'a str,
67 | module_title: &'a str,
68 | examples: bool,
69 | metadata: bool,
70 | generator_version: &'a str,
71 | current_day: &'a str,
72 | simplified: bool,
73 | }
74 |
75 | #[derive(Template)]
76 | #[template(path = "reference.adoc", escape = "none")]
77 | struct ReferenceTemplate<'a> {
78 | module_anchor: &'a str,
79 | module_title: &'a str,
80 | examples: bool,
81 | metadata: bool,
82 | generator_version: &'a str,
83 | current_day: &'a str,
84 | simplified: bool,
85 | }
86 |
87 | #[derive(Template)]
88 | #[template(path = "snippet.adoc", escape = "none")]
89 | struct SnippetTemplate<'a> {
90 | module_title: &'a str,
91 | examples: bool,
92 | metadata: bool,
93 | generator_version: &'a str,
94 | current_day: &'a str,
95 | // simplified: bool,
96 | }
97 |
98 | // We're implementing the template functions on the Input struct, not on Module,
99 | // because the templating happens at the point when newdoc composes the text of the module,
100 | // which is part of the module creation. The module then stores the rendered template.
101 | impl Input {
102 | /// Render the include statements that appear inside an assembly
103 | /// into the final format. If the assembly includes nothing, use
104 | /// a placeholder, or an empty string if examples are disabled.
105 | fn includes_block(&self) -> String {
106 | if let Some(include_statements) = &self.includes {
107 | // The includes should never be empty thanks to the required group in clap
108 | assert!(!include_statements.is_empty());
109 | // Join the includes into a block of text, with blank lines in between to prevent
110 | // the AsciiDoc syntax to blend between modules
111 | include_statements.join("\n\n")
112 | } else if self.options.examples {
113 | "Include modules here.".to_string()
114 | } else {
115 | String::new()
116 | }
117 | }
118 |
119 | /// Perform string replacements in the modular template that matches the `ContentType`.
120 | /// Return the template text with all replacements.
121 | #[must_use]
122 | pub fn text(&self) -> String {
123 | let generator_version = generator_version();
124 | let current_day = current_day();
125 |
126 | let mut document = match self.mod_type {
127 | ContentType::Assembly => AssemblyTemplate {
128 | module_anchor: &self.anchor(),
129 | module_title: &self.title,
130 | include_statements: &self.includes_block(),
131 | examples: self.options.examples,
132 | metadata: self.options.metadata,
133 | generator_version,
134 | current_day: ¤t_day,
135 | simplified: self.options.simplified,
136 | }
137 | .render(),
138 | ContentType::Concept => ConceptTemplate {
139 | module_anchor: &self.anchor(),
140 | module_title: &self.title,
141 | examples: self.options.examples,
142 | metadata: self.options.metadata,
143 | generator_version,
144 | current_day: ¤t_day,
145 | simplified: self.options.simplified,
146 | }
147 | .render(),
148 | ContentType::Procedure => ProcedureTemplate {
149 | module_anchor: &self.anchor(),
150 | module_title: &self.title,
151 | examples: self.options.examples,
152 | metadata: self.options.metadata,
153 | generator_version,
154 | current_day: ¤t_day,
155 | simplified: self.options.simplified,
156 | }
157 | .render(),
158 | ContentType::Reference => ReferenceTemplate {
159 | module_anchor: &self.anchor(),
160 | module_title: &self.title,
161 | examples: self.options.examples,
162 | metadata: self.options.metadata,
163 | generator_version,
164 | current_day: ¤t_day,
165 | simplified: self.options.simplified,
166 | }
167 | .render(),
168 | ContentType::Snippet => SnippetTemplate {
169 | module_title: &self.title,
170 | examples: self.options.examples,
171 | metadata: self.options.metadata,
172 | generator_version,
173 | current_day: ¤t_day,
174 | // simplified: self.options.simplified,
175 | }
176 | .render(),
177 | }
178 | .expect("Failed to construct the document from the template");
179 |
180 | // If comments are disabled via an option, delete comment lines from the content
181 | if !self.options.comments {
182 | // Delete multi-line (block) comments
183 | let multi_comments: Regex = RegexBuilder::new(r"^////[\s\S\n]*^////[\s]*\n")
184 | .multi_line(true)
185 | .swap_greed(true)
186 | .build()
187 | .expect(REGEX_ERROR);
188 | document = multi_comments.replace_all(&document, "").to_string();
189 |
190 | // Delete single-line comments
191 | let single_comments: Regex = RegexBuilder::new(r"^//.*\n")
192 | .multi_line(true)
193 | .swap_greed(true)
194 | .build()
195 | .expect(REGEX_ERROR);
196 | document = single_comments.replace_all(&document, "").to_string();
197 |
198 | // Delete leading white space left over by the deleted comments
199 | let leading_whitespace: Regex = RegexBuilder::new(r"^[\s\n]*")
200 | .multi_line(true)
201 | .build()
202 | .expect(REGEX_ERROR);
203 | document = leading_whitespace.replace(&document, "").to_string();
204 | }
205 |
206 | // Remove excess blank lines that might have been left by the various
207 | // replacement stages. Make sure that the result contains no more than one
208 | // consecutive blank line.
209 | let two_blanks = "\n\n\n";
210 | let one_blank = "\n\n";
211 |
212 | while document.contains(two_blanks) {
213 | document = document.replace(two_blanks, one_blank);
214 | }
215 |
216 | // Add newlines at the end of the document to prevent potential issues
217 | // when including two AsciiDoc files right next to each other.
218 | document + one_blank
219 | }
220 | }
221 |
222 | /// The version of this build of newdoc (such as 2.14.1).
223 | fn generator_version() -> &'static str {
224 | env!("CARGO_PKG_VERSION")
225 | }
226 |
227 | /// Format the current date as YYYY-MM-DD (such as 2023-10-12).
228 | fn current_day() -> String {
229 | let now = OffsetDateTime::now_utc();
230 | let year = now.year();
231 | let month: u8 = now.month().into();
232 | let day = now.day();
233 |
234 | // The `:02` formatting options ensure that month and day numbers are always
235 | // two digits, padded with a zero if necessary.
236 | // E.g. `2024-01-05` instead of `2024-1-5`.
237 | format!("{year}-{month:02}-{day:02}")
238 | }
239 |
--------------------------------------------------------------------------------
/src/write.rs:
--------------------------------------------------------------------------------
1 | /*
2 | newdoc: Generate pre-populated documentation modules formatted with AsciiDoc.
3 | Copyright (C) 2022 Marek Suchánek
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | use std::fs;
20 |
21 | use color_eyre::eyre::{eyre, Result, WrapErr};
22 | use dialoguer::{theme::ColorfulTheme, Confirm};
23 |
24 | use crate::module::Module;
25 | use crate::Options;
26 |
27 | impl Module {
28 | /// Write the generated module content to the path specified in `options` with the set file name.
29 | pub fn write_file(&self, options: &Options) -> Result<()> {
30 | // Compose the full (but still relative) file path from the target directory and the file name
31 | let full_path_buf = &options.target_dir.join(&self.file_name);
32 | let full_path = full_path_buf.as_path();
33 |
34 | log::debug!("Writing file `{}`", &full_path.display());
35 |
36 | // If the target file already exists, just print out an error
37 | if full_path.exists() {
38 | log::warn!("File already exists: {}", full_path.display());
39 |
40 | // A prompt enabling the user to overwrite the existing file
41 | let overwrite = Confirm::with_theme(&ColorfulTheme::default())
42 | .with_prompt("Do you want to overwrite it?")
43 | .wait_for_newline(true)
44 | // The default selection is "false", that is, don't overwrite the file.
45 | .default(false)
46 | .interact()?;
47 |
48 | if overwrite {
49 | log::warn!("→ Rewriting the file.");
50 | } else {
51 | log::info!("→ Preserving the existing file.");
52 | // Break from generating this particular module.
53 | // Other modules that might be in the queue will be generated on next iteration.
54 | return Ok(());
55 | }
56 | }
57 |
58 | // If the target file doesn't exist, try to write to it
59 | fs::write(full_path, &self.text)
60 | .wrap_err_with(|| eyre!("Failed to write the `{}` file.", &full_path.display()))?;
61 |
62 | // If the write succeeds, print the include statement
63 | log::debug!("Successfully written file `{}`", &full_path.display());
64 | log::info!("‣ File generated: {}", full_path.display());
65 | log::info!(" {}", self.include_statement);
66 |
67 | Ok(())
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/templates/README.md:
--------------------------------------------------------------------------------
1 | # templates
2 |
3 | This directory contains the templates that `newdoc` uses at runtime to generate new files.
4 |
5 | The templates are AsciiDoc files with additional directives for `newdoc` to replace certain parts of the content with generated text. Currently, `newdoc` uses the [Askama](https://github.com/djc/askama/) templating library to perform the substitutions in the templates.
6 |
7 | For more information on the Askama templating syntax, see [Template Syntax](https://djc.github.io/askama/template_syntax.html).
8 |
9 | ## What about the context attribute in the assembly?
10 |
11 | The assembly template features a complicated configuration of the context attribute. In the order of appearance, as found at the time of commit `8b7fed5e370e6448928d95d68447e444e82c397c`:
12 |
13 |
14 | - ```
15 | ifdef::context[:parent-context-of-{{module_anchor}}: {context}]
16 | ```
17 |
18 | If context is already defined before this assembly starts, save the original context value to a new attribute. The assembly will restore the original context at the end of the file.
19 |
20 | - ```
21 | ifndef::context[]
22 | [id="{{module_anchor}}"]
23 | endif::[]
24 | ifdef::context[]
25 | [id="{{module_anchor}}_{context}"]
26 | endif::[]
27 | = {{module_title}}
28 | ```
29 |
30 | If context is already defined before this assembly starts, append the original context to the end of the assembly ID. This is similar to the behavior of modules: a module ID is always composed of the name of the module itself and the ID of the assembly that includes the module.
31 |
32 | However, an assembly can stand on its own, or it can be included from the root of the guide where context might not be defined. in that situation, the assembly ID without context would end up in the form of `{{module_anchor}}_`, ending in an underscore. This is an invalid ID in some build systems.
33 |
34 | To work around the build system limitation, check whether context exists. If it doesn't exist, use an ID that is only based on the assembly name, without the context part.
35 |
36 | - Q: Why does an assembly even need context in its ID?
37 |
38 | - A: For the same reason as a module: So that you can reuse the assembly several times at different places of a guide.
39 |
40 | - ```
41 | :context: {{module_anchor}}
42 | ```
43 |
44 | Set a context attribute that modules inside of this assembly pick up and use in their IDs.
45 |
46 | - ```
47 | ifdef::parent-context-of-{{module_anchor}}[:context: {parent-context-of-{{module_anchor}}}]
48 | ifndef::parent-context-of-{{module_anchor}}[:!context:]
49 | ```
50 | When the assembly ends, restore the original context back to its value that it had before this assembly started.
51 |
52 | This step encapsulates the context just to the assembly, and as a result, all assemblies included on the same level inherit the same context attribute. For example, if a title defined context `A` and includes several assemblies, all of them use `A` in their IDs. Without this restoration step, each assembly would instead use the context of the previous assembly in the guide.
53 |
--------------------------------------------------------------------------------
/templates/assembly.adoc:
--------------------------------------------------------------------------------
1 | {% if metadata -%}
2 | :_newdoc-version: {{generator_version}}
3 | :_template-generated: {{current_day}}
4 | ////
5 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
6 | ////
7 | :_mod-docs-content-type: ASSEMBLY
8 | {%- endif %}
9 |
10 | {% if !simplified -%}
11 | ////
12 | Retains the context of the parent assembly if this assembly is nested within another assembly.
13 | For more information about nesting assemblies, see: https://redhat-documentation.github.io/modular-docs/#nesting-assemblies
14 | See also the complementary step on the last line of this file.
15 | ////
16 | ifdef::context[:parent-context-of-{{module_anchor}}: {context}]
17 | {%- endif %}
18 |
19 | ////
20 | Base the file name and the ID on the assembly title. For example:
21 | * file name: assembly-my-user-story.adoc
22 | * ID: [id="assembly-my-user-story_{context}"]
23 | * Title: = My user story
24 |
25 | ID is a unique identifier that can be used to reference this assembly. Avoid changing it after the module has been published to ensure existing links are not broken. Include {context} in the ID so the assembly can be reused.
26 |
27 | Be sure to include a line break between the title and the :context: variable and the :context: variable and the assembly introduction.
28 | If the assembly covers a task, start the title with a verb in the gerund form, such as Creating or Configuring.
29 | ////
30 | {% if simplified -%}
31 | [id="{{module_anchor}}"]
32 | {%- else -%}
33 | ifndef::context[]
34 | [id="{{module_anchor}}"]
35 | endif::[]
36 | ifdef::context[]
37 | [id="{{module_anchor}}_{context}"]
38 | endif::[]
39 | {%- endif %}
40 | = {{module_title}}
41 |
42 | {% if !simplified -%}
43 | ////
44 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
45 | ////
46 | :context: {{module_anchor}}
47 | {%- endif %}
48 |
49 | {% if examples -%}
50 | This paragraph is the assembly introduction. It explains what the user will accomplish by working through the modules in the assembly and sets the context for the user story the assembly is based on.
51 | {%- endif %}
52 |
53 | == Prerequisites
54 |
55 | {% if examples -%}
56 | * A bulleted list of conditions that must be satisfied before the user starts following this assembly.
57 | * You can also link to other modules or assemblies the user must follow before starting this assembly.
58 | * Delete the section title and bullets if the assembly has no prerequisites.
59 | * X is installed. For information about installing X, see .
60 | * You can log in to X with administrator privileges.
61 | {%- endif %}
62 |
63 | ////
64 | The following include statements pull in the module files that comprise the assembly. Include any combination of concept, procedure, or reference modules required to cover the user story. You can also include other assemblies.
65 |
66 | [leveloffset=+1] ensures that when a module title is a level 1 heading (= Title), the heading will be interpreted as a level-2 heading (== Title) in the assembly. Use [leveloffset=+2] and [leveloffset=+3] to nest modules in an assembly.
67 |
68 | Add a blank line after each 'include::' statement.
69 |
70 | include::modules/TEMPLATE_PROCEDURE_doing_one_procedure.adoc[leveloffset=+2]
71 |
72 | include::modules/TEMPLATE_PROCEDURE_reference-material.adoc[leveloffset=2]
73 | ////
74 | {{include_statements}}
75 |
76 | == Next steps
77 |
78 | {% if examples -%}
79 | * This section is optional.
80 | * Provide a bulleted list of links that contain instructions that might be useful to the user after they complete this procedure.
81 | * Use an unnumbered bullet (*) if the list includes only one step.
82 | {%- endif %}
83 |
84 | ////
85 | Optional. Delete if not used.
86 |
87 | Provide a bulleted list of links and display text relevant to the assembly. These links can include `link:` and `xref:` macros. Do not include additional text.
88 |
89 | If the last module included in your assembly contains an Additional resources section as well, check the appearance of the rendered assembly. If the two Additional resources sections might be confusing for a reader, consider consolidating their content and removing one of them.
90 | ////
91 | [role="_additional-resources"]
92 | == Additional resources
93 |
94 | {% if examples -%}
95 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
96 | * xref:some-module_{context}[]
97 | {%- endif %}
98 |
99 | {% if !simplified -%}
100 | ////
101 | Restore the context to what it was before this assembly.
102 | ////
103 | ifdef::parent-context-of-{{module_anchor}}[:context: {parent-context-of-{{module_anchor}}}]
104 | ifndef::parent-context-of-{{module_anchor}}[:!context:]
105 | {%- endif %}
--------------------------------------------------------------------------------
/templates/concept.adoc:
--------------------------------------------------------------------------------
1 | {% if metadata -%}
2 | :_newdoc-version: {{generator_version}}
3 | :_template-generated: {{current_day}}
4 | ////
5 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
6 | ////
7 | :_mod-docs-content-type: CONCEPT
8 | {%- endif %}
9 |
10 | ////
11 | Base the file name and the ID on the module title. For example:
12 | * file name: con_my-concept-module-a.adoc
13 | * ID: [id="my-concept-module-a_{context}"]
14 | * Title: = My concept module A
15 |
16 | ID is a unique identifier that can be used to reference this module. Avoid changing it after the module has been published to ensure existing links are not broken.
17 |
18 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
19 |
20 | Be sure to include a line break between the title and the module introduction.
21 | ////
22 | {% if simplified -%}
23 | [id="{{module_anchor}}"]
24 | {%- else -%}
25 | [id="{{module_anchor}}_{context}"]
26 | {%- endif %}
27 | = {{module_title}}
28 | ////
29 | In the title of concept modules, include nouns or noun phrases that are used in the body text. This helps readers and search engines find the information quickly. Do not start the title of concept modules with a verb or gerund. See also _Wording of headings_ in _IBM Style_.
30 | ////
31 |
32 | {% if examples -%}
33 | Write a short introductory paragraph that provides an overview of the module.
34 |
35 | The contents of a concept module give the user descriptions and explanations needed to understand and use a product.
36 |
37 | * Look at nouns and noun phrases in related procedure modules and assemblies to find the concepts to explain to users.
38 | * Explain only things that are visible to users. Even if a concept is interesting, it probably does not require explanation if it is not visible to users.
39 | * Avoid including action items. Action items belong in procedure modules. However, in some cases a concept or reference can include suggested actions when those actions are simple, are highly dependent on the context of the module, and have no place in any procedure module. In such cases, ensure that the heading of the concept or reference remains a noun phrase and not a gerund.
40 |
41 | ////
42 | Do not include third-level headings (===).
43 |
44 | Include titles and alternative text descriptions for images and enclose the descriptions in straight quotation marks (""). Alternative text should provide a textual, complete description of the image as a full sentence.
45 |
46 | Images should never be the sole means of conveying information and should only supplement the text.
47 |
48 | Avoid screenshots or other images that might quickly go out of date and that create a maintenance burden on documentation. Provide text equivalents for every diagram, image, or other non-text element. Avoid using images of text instead of actual text.
49 |
50 | Example image:
51 |
52 | .Image title
53 | image::image-file.png["A textual representation of the essential information conveyed by the image."]
54 | ////
55 | {%- endif %}
56 |
57 | ////
58 | Optional. Delete if not used.
59 |
60 | Provide a bulleted list of links and display text relevant to the concept module. These links can include `link:` and `xref:` macros. Do not include additional text.
61 | ////
62 | [role="_additional-resources"]
63 | .Additional resources
64 | {% if examples -%}
65 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
66 | * xref:some-module_{context}[]
67 | {%- endif %}
--------------------------------------------------------------------------------
/templates/procedure.adoc:
--------------------------------------------------------------------------------
1 | {% if metadata -%}
2 | :_newdoc-version: {{generator_version}}
3 | :_template-generated: {{current_day}}
4 | ////
5 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
6 | ////
7 | :_mod-docs-content-type: PROCEDURE
8 | {%- endif %}
9 |
10 | ////
11 | Base the file name and the ID on the module title. For example:
12 | * file name: proc_doing-procedure-a.adoc
13 | * ID: [id="doing-procedure-a_{context}"]
14 | * Title: = Doing procedure A
15 |
16 | ID is a unique identifier that can be used to reference this module. Avoid changing it after the module has been published to ensure existing links are not broken.
17 |
18 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
19 |
20 | Be sure to include a line break between the title and the module introduction.
21 | ////
22 | {% if simplified -%}
23 | [id="{{module_anchor}}"]
24 | {%- else -%}
25 | [id="{{module_anchor}}_{context}"]
26 | {%- endif %}
27 | = {{module_title}}
28 | ////
29 | Start the title of a procedure module with a gerund, such as Creating, Installing, or Deploying.
30 | ////
31 |
32 | {% if examples -%}
33 | Write a short introductory paragraph that provides an overview of the module. The introduction should include what the module will help the user do and why it will be beneficial to the user. Include key words that relate to the module to maximize search engine optimization.
34 | {%- endif %}
35 |
36 | .Prerequisites
37 | {% if examples -%}
38 | * A bulleted list of conditions that must be satisfied before the user starts the steps in this module.
39 | * Prerequisites can be full sentences or sentence fragments; however, prerequisite list items must be parallel.
40 | * Do not use imperative statements in the Prerequisites section.
41 | {%- endif %}
42 |
43 | .Procedure
44 | {% if examples -%}
45 | . Make each step an instruction.
46 | . Include one imperative sentence for each step, for example:
47 | .. Do this thing and then select *Next*.
48 | .. Do this other thing, and this other thing, and then select *Next*.
49 | . Use an unnumbered bullet (*) if the procedure includes only one step.
50 | +
51 | NOTE: You can add text, tables, code examples, images, and other items to a step. However, these items must be connected to the step with a plus sign (+). Any items under the .Procedure heading and before one of the following approved headings that are not connected to the last step with a plus sign cannot be converted to DITA.
52 | {%- endif %}
53 |
54 | ////
55 | Only the following block titles can be reliably mapped to DITA:
56 |
57 | * Prerequisites or Prerequisite
58 | * Procedure
59 | * Verification, Results, or Result
60 | * Troubleshooting, Troubleshooting steps, or Troubleshooting step
61 | * Next steps or Next step
62 | * Additional resources
63 |
64 | With the exception of Additional resources, these titles are only allowed in a procedure module. You can use each title exactly once and cannot use two different variants of the same title in the same module.
65 |
66 | Additionally, you can use block titles for figures, tables, and example blocks.
67 | ////
68 | .Verification
69 | {% if examples -%}
70 | Delete this section if it does not apply to your module. Provide the user with verification methods for the procedure, such as expected output or commands that confirm success or failure.
71 |
72 | * Provide an example of expected command output or a pop-up window that the user receives when the procedure is successful.
73 | * List actions for the user to complete, such as entering a command, to determine the success or failure of the procedure.
74 | * Make each step an instruction.
75 | * Use an unnumbered bullet (*) if the verification includes only one step.
76 | {%- endif %}
77 |
78 | .Troubleshooting
79 | {% if examples -%}
80 | Delete this section if it does not apply to your module. Provide the user with troubleshooting steps.
81 |
82 | * Make each step an instruction.
83 | * Use an unnumbered bullet (*) if the troubleshooting includes only one step.
84 | {%- endif %}
85 |
86 | .Next steps
87 | {% if examples -%}
88 | * Delete this section if it does not apply to your module.
89 | * Provide a bulleted list of links that contain instructions that might be useful to the user after they complete this procedure.
90 | * Use an unnumbered bullet (*) if the list includes only one step.
91 |
92 | NOTE: Do not use *Next steps* to provide a second list of instructions.
93 | {%- endif %}
94 |
95 | ////
96 | Optional. Delete if not used.
97 |
98 | Provide a bulleted list of links and display text relevant to the procedure module. These links can include `link:` and `xref:` macros. Do not include additional text.
99 | ////
100 | [role="_additional-resources"]
101 | .Additional resources
102 | {% if examples -%}
103 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
104 | * xref:some-module_{context}[]
105 | {%- endif %}
--------------------------------------------------------------------------------
/templates/reference.adoc:
--------------------------------------------------------------------------------
1 | {% if metadata -%}
2 | :_newdoc-version: {{generator_version}}
3 | :_template-generated: {{current_day}}
4 | ////
5 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
6 | ////
7 | :_mod-docs-content-type: REFERENCE
8 | {%- endif %}
9 |
10 | ////
11 | Base the file name and the ID on the module title. For example:
12 | * file name: ref_my-reference-a.adoc
13 | * ID: [id="my-reference-a_{context}"]
14 | * Title: = My reference A
15 |
16 | ID is a unique identifier that can be used to reference this module. Avoid changing it after the module has been published to ensure existing links are not broken.
17 |
18 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
19 |
20 | Be sure to include a line break between the title and the module introduction.
21 | ////
22 | {% if simplified -%}
23 | [id="{{module_anchor}}"]
24 | {%- else -%}
25 | [id="{{module_anchor}}_{context}"]
26 | {%- endif %}
27 | = {{module_title}}
28 | ////
29 | In the title of a reference module, include nouns that are used in the body text. For example, "Keyboard shortcuts for ___" or "Command options for ___." This helps readers and search engines find the information quickly.
30 | on.
31 | ////
32 |
33 | {% if examples -%}
34 | Write a short introductory paragraph that provides an overview of the module.
35 |
36 | A reference module provides data that users might want to look up, but do not need to remember. It has a very strict structure, often in the form of a list or a table. A well-organized reference module enables users to scan it quickly to find the details they want.
37 |
38 | AsciiDoc markup to consider for reference data:
39 |
40 | .Unordered list
41 | * For more details on writing reference modules, see the link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide].
42 | * Use a consistent system for file names, IDs, and titles.
43 | For tips, see _Anchor Names and File Names_ in link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide].
44 |
45 | .Labeled list
46 | Term 1:: Definition
47 | Term 2:: Definition
48 |
49 | .Table
50 | [options="header"]
51 | |====
52 | |Column 1|Column 2|Column 3
53 | |Row 1, column 1|Row 1, column 2|Row 1, column 3
54 | |Row 2, column 1|Row 2, column 2|Row 2, column 3
55 | |====
56 | {%- endif %}
57 |
58 | ////
59 | Optional. Delete if not used.
60 |
61 | Provide a bulleted list of links and display text relevant to the reference module. These links can include `link:` and `xref:` macros. Do not include additional text.
62 | ////
63 | [role="_additional-resources"]
64 | .Additional resources
65 | {% if examples -%}
66 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
67 | * xref:some-module_{context}[]
68 | {%- endif %}
--------------------------------------------------------------------------------
/templates/snippet.adoc:
--------------------------------------------------------------------------------
1 | {% if metadata -%}
2 | :_newdoc-version: {{generator_version}}
3 | :_template-generated: {{current_day}}
4 | {%- endif %}
5 | ////
6 | Base the file name on the snippet title. For example:
7 | * file name: snip-my-snippet-a.adoc
8 | * Title: .My snippet A
9 |
10 | A snippet is not a module. Consider storing snippet files in a separate snippets folder.
11 |
12 | Indicate the content type in one of the following ways:
13 | Add the prefix snip- or snip_ to the file name.
14 | Add the following attribute before the title:
15 | :_mod-docs-content-type: SNIPPET
16 | ////
17 | {% if metadata -%}
18 | :_mod-docs-content-type: SNIPPET
19 | {%- endif %}
20 |
21 | .{{module_title}}
22 | ////
23 | The title is optional in a snippet. Use the block title syntax, such as .My snippet A, rather than a numbered heading, such as = My snippet A.
24 |
25 | In the title of snippets, include nouns or noun phrases that are used in the body text. This helps readers and search engines find the information quickly. Do not start the title of snippets with a verb. See also _Wording of headings_ in _The IBM Style Guide_.
26 |
27 | Do not specify an ID for the snippet title.
28 | ////
29 |
30 | {% if examples -%}
31 | A text snippet is a small fragment of text that is stored in an AsciiDoc file. Text snippets contain content that is reused in multiple modules or assemblies, for example:
32 |
33 | * A step or series of steps in a procedure
34 | * A disclaimer, for example, for technology preview or beta releases
35 |
36 | [NOTE]
37 | --
38 | Additional guidance or advice that improves product configuration, performance, or supportability.
39 | --
40 |
41 | [IMPORTANT]
42 | --
43 | Advisory information essential to the completion of a task. Users must not disregard this information.
44 | --
45 |
46 | [WARNING]
47 | --
48 | Information about potential system damage, data loss, or a support-related issue if the user disregards this admonition. Explain the problem, cause, and offer a solution that works. If available, offer information to avoid the problem in the future or state where to find more information.
49 | --
50 | {%- endif %}
51 |
--------------------------------------------------------------------------------
/tests/generated/README.md:
--------------------------------------------------------------------------------
1 | # generated
2 |
3 | This directory contains static, fully generated module files created by a released version of `newdoc`. These files serve mainly as test targets to check that `newdoc` continues to generate the exact same output.
4 |
5 |
--------------------------------------------------------------------------------
/tests/generated/assembly_testing-that-an-assembly-forms-properly.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: {{generator_version}}
2 | :_template-generated: {{current_day}}
3 | ////
4 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
5 | ////
6 | :_mod-docs-content-type: ASSEMBLY
7 |
8 | ////
9 | Retains the context of the parent assembly if this assembly is nested within another assembly.
10 | For more information about nesting assemblies, see: https://redhat-documentation.github.io/modular-docs/#nesting-assemblies
11 | See also the complementary step on the last line of this file.
12 | ////
13 | ifdef::context[:parent-context-of-testing-that-an-assembly-forms-properly: {context}]
14 |
15 | ////
16 | Base the file name and the ID on the assembly title. For example:
17 | * file name: assembly-my-user-story.adoc
18 | * ID: [id="assembly-my-user-story_{context}"]
19 | * Title: = My user story
20 |
21 | ID is a unique identifier that can be used to reference this assembly. Avoid changing it after the module has been published to ensure existing links are not broken. Include {context} in the ID so the assembly can be reused.
22 |
23 | Be sure to include a line break between the title and the :context: variable and the :context: variable and the assembly introduction.
24 | If the assembly covers a task, start the title with a verb in the gerund form, such as Creating or Configuring.
25 | ////
26 | ifndef::context[]
27 | [id="testing-that-an-assembly-forms-properly"]
28 | endif::[]
29 | ifdef::context[]
30 | [id="testing-that-an-assembly-forms-properly_{context}"]
31 | endif::[]
32 | = Testing that an assembly forms properly
33 |
34 | ////
35 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
36 | ////
37 | :context: testing-that-an-assembly-forms-properly
38 |
39 | This paragraph is the assembly introduction. It explains what the user will accomplish by working through the modules in the assembly and sets the context for the user story the assembly is based on.
40 |
41 | == Prerequisites
42 |
43 | * A bulleted list of conditions that must be satisfied before the user starts following this assembly.
44 | * You can also link to other modules or assemblies the user must follow before starting this assembly.
45 | * Delete the section title and bullets if the assembly has no prerequisites.
46 | * X is installed. For information about installing X, see .
47 | * You can log in to X with administrator privileges.
48 |
49 | ////
50 | The following include statements pull in the module files that comprise the assembly. Include any combination of concept, procedure, or reference modules required to cover the user story. You can also include other assemblies.
51 |
52 | [leveloffset=+1] ensures that when a module title is a level 1 heading (= Title), the heading will be interpreted as a level-2 heading (== Title) in the assembly. Use [leveloffset=+2] and [leveloffset=+3] to nest modules in an assembly.
53 |
54 | Add a blank line after each 'include::' statement.
55 |
56 | include::modules/TEMPLATE_PROCEDURE_doing_one_procedure.adoc[leveloffset=+2]
57 |
58 | include::modules/TEMPLATE_PROCEDURE_reference-material.adoc[leveloffset=2]
59 | ////
60 | Include modules here.
61 |
62 | == Next steps
63 |
64 | * This section is optional.
65 | * Provide a bulleted list of links that contain instructions that might be useful to the user after they complete this procedure.
66 | * Use an unnumbered bullet (*) if the list includes only one step.
67 |
68 | ////
69 | Optional. Delete if not used.
70 |
71 | Provide a bulleted list of links and display text relevant to the assembly. These links can include `link:` and `xref:` macros. Do not include additional text.
72 |
73 | If the last module included in your assembly contains an Additional resources section as well, check the appearance of the rendered assembly. If the two Additional resources sections might be confusing for a reader, consider consolidating their content and removing one of them.
74 | ////
75 | [role="_additional-resources"]
76 | == Additional resources
77 |
78 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
79 | * xref:some-module_{context}[]
80 |
81 | ////
82 | Restore the context to what it was before this assembly.
83 | ////
84 | ifdef::parent-context-of-testing-that-an-assembly-forms-properly[:context: {parent-context-of-testing-that-an-assembly-forms-properly}]
85 | ifndef::parent-context-of-testing-that-an-assembly-forms-properly[:!context:]
86 |
87 |
--------------------------------------------------------------------------------
/tests/generated/con_a-title-that-tests-a-concept.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: {{generator_version}}
2 | :_template-generated: {{current_day}}
3 | ////
4 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
5 | ////
6 | :_mod-docs-content-type: CONCEPT
7 |
8 | ////
9 | Base the file name and the ID on the module title. For example:
10 | * file name: con_my-concept-module-a.adoc
11 | * ID: [id="my-concept-module-a_{context}"]
12 | * Title: = My concept module A
13 |
14 | ID is a unique identifier that can be used to reference this module. Avoid changing it after the module has been published to ensure existing links are not broken.
15 |
16 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
17 |
18 | Be sure to include a line break between the title and the module introduction.
19 | ////
20 | [id="a-title-that-tests-a-concept_{context}"]
21 | = A title that tests a concept
22 | ////
23 | In the title of concept modules, include nouns or noun phrases that are used in the body text. This helps readers and search engines find the information quickly. Do not start the title of concept modules with a verb or gerund. See also _Wording of headings_ in _IBM Style_.
24 | ////
25 |
26 | Write a short introductory paragraph that provides an overview of the module.
27 |
28 | The contents of a concept module give the user descriptions and explanations needed to understand and use a product.
29 |
30 | * Look at nouns and noun phrases in related procedure modules and assemblies to find the concepts to explain to users.
31 | * Explain only things that are visible to users. Even if a concept is interesting, it probably does not require explanation if it is not visible to users.
32 | * Avoid including action items. Action items belong in procedure modules. However, in some cases a concept or reference can include suggested actions when those actions are simple, are highly dependent on the context of the module, and have no place in any procedure module. In such cases, ensure that the heading of the concept or reference remains a noun phrase and not a gerund.
33 |
34 | ////
35 | Do not include third-level headings (===).
36 |
37 | Include titles and alternative text descriptions for images and enclose the descriptions in straight quotation marks (""). Alternative text should provide a textual, complete description of the image as a full sentence.
38 |
39 | Images should never be the sole means of conveying information and should only supplement the text.
40 |
41 | Avoid screenshots or other images that might quickly go out of date and that create a maintenance burden on documentation. Provide text equivalents for every diagram, image, or other non-text element. Avoid using images of text instead of actual text.
42 |
43 | Example image:
44 |
45 | .Image title
46 | image::image-file.png["A textual representation of the essential information conveyed by the image."]
47 | ////
48 |
49 | ////
50 | Optional. Delete if not used.
51 |
52 | Provide a bulleted list of links and display text relevant to the concept module. These links can include `link:` and `xref:` macros. Do not include additional text.
53 | ////
54 | [role="_additional-resources"]
55 | .Additional resources
56 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
57 | * xref:some-module_{context}[]
58 |
59 |
--------------------------------------------------------------------------------
/tests/generated/minimal-assembly.adoc:
--------------------------------------------------------------------------------
1 | [id="minimal-assembly"]
2 | = Minimal assembly
3 |
4 | == Prerequisites
5 |
6 | == Next steps
7 |
8 | [role="_additional-resources"]
9 | == Additional resources
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/tests/generated/minimal-concept.adoc:
--------------------------------------------------------------------------------
1 | [id="minimal-concept"]
2 | = Minimal concept
3 |
4 | [role="_additional-resources"]
5 | .Additional resources
6 |
7 |
8 |
--------------------------------------------------------------------------------
/tests/generated/minimal-procedure.adoc:
--------------------------------------------------------------------------------
1 | [id="minimal-procedure"]
2 | = Minimal procedure
3 |
4 | .Prerequisites
5 |
6 | .Procedure
7 |
8 | .Verification
9 |
10 | .Troubleshooting
11 |
12 | .Next steps
13 |
14 | [role="_additional-resources"]
15 | .Additional resources
16 |
17 |
18 |
--------------------------------------------------------------------------------
/tests/generated/minimal-reference.adoc:
--------------------------------------------------------------------------------
1 | [id="minimal-reference"]
2 | = Minimal reference
3 |
4 | [role="_additional-resources"]
5 | .Additional resources
6 |
7 |
8 |
--------------------------------------------------------------------------------
/tests/generated/minimal-snippet.adoc:
--------------------------------------------------------------------------------
1 | .Minimal snippet
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/tests/generated/proc_testing-a-procedure.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: {{generator_version}}
2 | :_template-generated: {{current_day}}
3 | ////
4 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
5 | ////
6 | :_mod-docs-content-type: PROCEDURE
7 |
8 | ////
9 | Base the file name and the ID on the module title. For example:
10 | * file name: proc_doing-procedure-a.adoc
11 | * ID: [id="doing-procedure-a_{context}"]
12 | * Title: = Doing procedure A
13 |
14 | ID is a unique identifier that can be used to reference this module. Avoid changing it after the module has been published to ensure existing links are not broken.
15 |
16 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
17 |
18 | Be sure to include a line break between the title and the module introduction.
19 | ////
20 | [id="testing-a-procedure_{context}"]
21 | = Testing a procedure
22 | ////
23 | Start the title of a procedure module with a gerund, such as Creating, Installing, or Deploying.
24 | ////
25 |
26 | Write a short introductory paragraph that provides an overview of the module. The introduction should include what the module will help the user do and why it will be beneficial to the user. Include key words that relate to the module to maximize search engine optimization.
27 |
28 | .Prerequisites
29 | * A bulleted list of conditions that must be satisfied before the user starts the steps in this module.
30 | * Prerequisites can be full sentences or sentence fragments; however, prerequisite list items must be parallel.
31 | * Do not use imperative statements in the Prerequisites section.
32 |
33 | .Procedure
34 | . Make each step an instruction.
35 | . Include one imperative sentence for each step, for example:
36 | .. Do this thing and then select *Next*.
37 | .. Do this other thing, and this other thing, and then select *Next*.
38 | . Use an unnumbered bullet (*) if the procedure includes only one step.
39 | +
40 | NOTE: You can add text, tables, code examples, images, and other items to a step. However, these items must be connected to the step with a plus sign (+). Any items under the .Procedure heading and before one of the following approved headings that are not connected to the last step with a plus sign cannot be converted to DITA.
41 |
42 | ////
43 | Only the following block titles can be reliably mapped to DITA:
44 |
45 | * Prerequisites or Prerequisite
46 | * Procedure
47 | * Verification, Results, or Result
48 | * Troubleshooting, Troubleshooting steps, or Troubleshooting step
49 | * Next steps or Next step
50 | * Additional resources
51 |
52 | With the exception of Additional resources, these titles are only allowed in a procedure module. You can use each title exactly once and cannot use two different variants of the same title in the same module.
53 |
54 | Additionally, you can use block titles for figures, tables, and example blocks.
55 | ////
56 | .Verification
57 | Delete this section if it does not apply to your module. Provide the user with verification methods for the procedure, such as expected output or commands that confirm success or failure.
58 |
59 | * Provide an example of expected command output or a pop-up window that the user receives when the procedure is successful.
60 | * List actions for the user to complete, such as entering a command, to determine the success or failure of the procedure.
61 | * Make each step an instruction.
62 | * Use an unnumbered bullet (*) if the verification includes only one step.
63 |
64 | .Troubleshooting
65 | Delete this section if it does not apply to your module. Provide the user with troubleshooting steps.
66 |
67 | * Make each step an instruction.
68 | * Use an unnumbered bullet (*) if the troubleshooting includes only one step.
69 |
70 | .Next steps
71 | * Delete this section if it does not apply to your module.
72 | * Provide a bulleted list of links that contain instructions that might be useful to the user after they complete this procedure.
73 | * Use an unnumbered bullet (*) if the list includes only one step.
74 |
75 | NOTE: Do not use *Next steps* to provide a second list of instructions.
76 |
77 | ////
78 | Optional. Delete if not used.
79 |
80 | Provide a bulleted list of links and display text relevant to the procedure module. These links can include `link:` and `xref:` macros. Do not include additional text.
81 | ////
82 | [role="_additional-resources"]
83 | .Additional resources
84 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
85 | * xref:some-module_{context}[]
86 |
87 |
--------------------------------------------------------------------------------
/tests/generated/ref_the-lines-in-a-reference-module.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: {{generator_version}}
2 | :_template-generated: {{current_day}}
3 | ////
4 | Metadata attribute that will help enable correct parsing and conversion to the appropriate DITA topic type.
5 | ////
6 | :_mod-docs-content-type: REFERENCE
7 |
8 | ////
9 | Base the file name and the ID on the module title. For example:
10 | * file name: ref_my-reference-a.adoc
11 | * ID: [id="my-reference-a_{context}"]
12 | * Title: = My reference A
13 |
14 | ID is a unique identifier that can be used to reference this module. Avoid changing it after the module has been published to ensure existing links are not broken.
15 |
16 | The `context` attribute enables module reuse. Every module ID includes {context}, which ensures that the module has a unique ID so you can include it multiple times in the same guide.
17 |
18 | Be sure to include a line break between the title and the module introduction.
19 | ////
20 | [id="the-lines-in-a-reference-module_{context}"]
21 | = The lines in a reference module
22 | ////
23 | In the title of a reference module, include nouns that are used in the body text. For example, "Keyboard shortcuts for ___" or "Command options for ___." This helps readers and search engines find the information quickly.
24 | on.
25 | ////
26 |
27 | Write a short introductory paragraph that provides an overview of the module.
28 |
29 | A reference module provides data that users might want to look up, but do not need to remember. It has a very strict structure, often in the form of a list or a table. A well-organized reference module enables users to scan it quickly to find the details they want.
30 |
31 | AsciiDoc markup to consider for reference data:
32 |
33 | .Unordered list
34 | * For more details on writing reference modules, see the link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide].
35 | * Use a consistent system for file names, IDs, and titles.
36 | For tips, see _Anchor Names and File Names_ in link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide].
37 |
38 | .Labeled list
39 | Term 1:: Definition
40 | Term 2:: Definition
41 |
42 | .Table
43 | [options="header"]
44 | |====
45 | |Column 1|Column 2|Column 3
46 | |Row 1, column 1|Row 1, column 2|Row 1, column 3
47 | |Row 2, column 1|Row 2, column 2|Row 2, column 3
48 | |====
49 |
50 | ////
51 | Optional. Delete if not used.
52 |
53 | Provide a bulleted list of links and display text relevant to the reference module. These links can include `link:` and `xref:` macros. Do not include additional text.
54 | ////
55 | [role="_additional-resources"]
56 | .Additional resources
57 | * link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide]
58 | * xref:some-module_{context}[]
59 |
60 |
--------------------------------------------------------------------------------
/tests/generated/snip_some-notes-in-a-snippet-file.adoc:
--------------------------------------------------------------------------------
1 | :_newdoc-version: {{generator_version}}
2 | :_template-generated: {{current_day}}
3 | ////
4 | Base the file name on the snippet title. For example:
5 | * file name: snip-my-snippet-a.adoc
6 | * Title: .My snippet A
7 |
8 | A snippet is not a module. Consider storing snippet files in a separate snippets folder.
9 |
10 | Indicate the content type in one of the following ways:
11 | Add the prefix snip- or snip_ to the file name.
12 | Add the following attribute before the title:
13 | :_mod-docs-content-type: SNIPPET
14 | ////
15 | :_mod-docs-content-type: SNIPPET
16 |
17 | .Some notes in a snippet file
18 | ////
19 | The title is optional in a snippet. Use the block title syntax, such as .My snippet A, rather than a numbered heading, such as = My snippet A.
20 |
21 | In the title of snippets, include nouns or noun phrases that are used in the body text. This helps readers and search engines find the information quickly. Do not start the title of snippets with a verb. See also _Wording of headings_ in _The IBM Style Guide_.
22 |
23 | Do not specify an ID for the snippet title.
24 | ////
25 |
26 | A text snippet is a small fragment of text that is stored in an AsciiDoc file. Text snippets contain content that is reused in multiple modules or assemblies, for example:
27 |
28 | * A step or series of steps in a procedure
29 | * A disclaimer, for example, for technology preview or beta releases
30 |
31 | [NOTE]
32 | --
33 | Additional guidance or advice that improves product configuration, performance, or supportability.
34 | --
35 |
36 | [IMPORTANT]
37 | --
38 | Advisory information essential to the completion of a task. Users must not disregard this information.
39 | --
40 |
41 | [WARNING]
42 | --
43 | Information about potential system damage, data loss, or a support-related issue if the user disregards this admonition. Explain the problem, cause, and offer a solution that works. If available, offer information to avoid the problem in the future or state where to find more information.
44 | --
45 |
46 |
--------------------------------------------------------------------------------
/tests/integration.rs:
--------------------------------------------------------------------------------
1 | //! These are integration tests. They let the top-level functions generate
2 | //! each module type and then they compare the generated content with a pre-generated specimen
3 | //! to check that we introduce no changes unknowingly.
4 |
5 | use std::path::PathBuf;
6 | use time::OffsetDateTime;
7 |
8 | use cmd_line::Verbosity;
9 | use newdoc::*;
10 |
11 | // These values represent the default newdoc options.
12 | fn basic_options() -> Options {
13 | Options {
14 | comments: true,
15 | file_prefixes: true,
16 | anchor_prefixes: false,
17 | examples: true,
18 | target_dir: PathBuf::from("."),
19 | verbosity: Verbosity::Default,
20 | ..Default::default()
21 | }
22 | }
23 |
24 | /// The version of this build of newdoc (such as 2.14.1).
25 | fn generator_version() -> &'static str {
26 | env!("CARGO_PKG_VERSION")
27 | }
28 |
29 | /// Format the current date as YYYY-MM-DD (such as 2023-10-12).
30 | fn current_day() -> String {
31 | let now = OffsetDateTime::now_utc();
32 | let year = now.year();
33 | let month: u8 = now.month().into();
34 | let day = now.day();
35 |
36 | format!("{year}-{month:02}-{day:02}")
37 | }
38 |
39 | /// Test that we generate the assembly that we expect.
40 | #[test]
41 | fn test_assembly() {
42 | let mod_type = ContentType::Assembly;
43 | let mod_title = "Testing that an assembly forms properly";
44 | let options = basic_options();
45 | let assembly = Module::new(mod_type, mod_title, &options);
46 |
47 | let pre_generated =
48 | include_str!("./generated/assembly_testing-that-an-assembly-forms-properly.adoc");
49 | // Replace the version and date placeholders:
50 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
51 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
52 |
53 | assert_eq!(assembly.text, pre_generated);
54 | }
55 |
56 | /// Test that we generate the concept module that we expect.
57 | #[test]
58 | fn test_concept_module() {
59 | let mod_type = ContentType::Concept;
60 | let mod_title = "A title that tests a concept";
61 | let options = basic_options();
62 | let concept = Module::new(mod_type, mod_title, &options);
63 |
64 | let pre_generated = include_str!("./generated/con_a-title-that-tests-a-concept.adoc");
65 | // Replace the version and date placeholders:
66 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
67 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
68 |
69 | assert_eq!(concept.text, pre_generated);
70 | }
71 |
72 | /// Test that we generate the procedure module that we expect.
73 | #[test]
74 | fn test_procedure_module() {
75 | let mod_type = ContentType::Procedure;
76 | let mod_title = "Testing a procedure";
77 | let options = basic_options();
78 | let procedure = Module::new(mod_type, mod_title, &options);
79 |
80 | let pre_generated = include_str!("./generated/proc_testing-a-procedure.adoc");
81 | // Replace the version and date placeholders:
82 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
83 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
84 |
85 | assert_eq!(procedure.text, pre_generated);
86 | }
87 |
88 | /// Test that we generate the reference module that we expect.
89 | #[test]
90 | fn test_reference_module() {
91 | let mod_type = ContentType::Reference;
92 | let mod_title = "The lines in a reference module";
93 | let options = basic_options();
94 | let reference = Module::new(mod_type, mod_title, &options);
95 |
96 | let pre_generated = include_str!("./generated/ref_the-lines-in-a-reference-module.adoc");
97 | // Replace the version and date placeholders:
98 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
99 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
100 |
101 | assert_eq!(reference.text, pre_generated);
102 | }
103 |
104 | /// Test that we generate the snippet file that we expect.
105 | #[test]
106 | fn test_snippet_file() {
107 | let mod_type = ContentType::Snippet;
108 | let mod_title = "Some notes in a snippet file";
109 | let options = basic_options();
110 | let snippet = Module::new(mod_type, mod_title, &options);
111 |
112 | let pre_generated = include_str!("./generated/snip_some-notes-in-a-snippet-file.adoc");
113 | // Replace the version and date placeholders:
114 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
115 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
116 |
117 | assert_eq!(snippet.text, pre_generated);
118 | }
119 |
120 | // These values strip down the modules to the bare minimum.
121 | fn minimal_options() -> Options {
122 | Options {
123 | comments: false,
124 | file_prefixes: true,
125 | anchor_prefixes: false,
126 | examples: false,
127 | metadata: false,
128 | target_dir: PathBuf::from("."),
129 | verbosity: Verbosity::Default,
130 | simplified: true,
131 | }
132 | }
133 |
134 | /// Test that we generate the assembly that we expect.
135 | #[test]
136 | fn test_minimal_assembly() {
137 | let mod_type = ContentType::Assembly;
138 | let mod_title = "Minimal assembly";
139 | let options = minimal_options();
140 | let assembly = Module::new(mod_type, mod_title, &options);
141 |
142 | let pre_generated = include_str!("./generated/minimal-assembly.adoc");
143 | // Replace the version and date placeholders:
144 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
145 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
146 |
147 | assert_eq!(assembly.text, pre_generated);
148 | }
149 |
150 | /// Test that we generate the concept module that we expect.
151 | #[test]
152 | fn test_minimal_concept() {
153 | let mod_type = ContentType::Concept;
154 | let mod_title = "Minimal concept";
155 | let options = minimal_options();
156 | let concept = Module::new(mod_type, mod_title, &options);
157 |
158 | let pre_generated = include_str!("./generated/minimal-concept.adoc");
159 | // Replace the version and date placeholders:
160 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
161 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
162 |
163 | assert_eq!(concept.text, pre_generated);
164 | }
165 |
166 | /// Test that we generate the procedure module that we expect.
167 | #[test]
168 | fn test_minimal_procedure() {
169 | let mod_type = ContentType::Procedure;
170 | let mod_title = "Minimal procedure";
171 | let options = minimal_options();
172 | let procedure = Module::new(mod_type, mod_title, &options);
173 |
174 | let pre_generated = include_str!("./generated/minimal-procedure.adoc");
175 | // Replace the version and date placeholders:
176 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
177 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
178 |
179 | assert_eq!(procedure.text, pre_generated);
180 | }
181 |
182 | /// Test that we generate the reference module that we expect.
183 | #[test]
184 | fn test_minimal_reference() {
185 | let mod_type = ContentType::Reference;
186 | let mod_title = "Minimal reference";
187 | let options = minimal_options();
188 | let reference = Module::new(mod_type, mod_title, &options);
189 |
190 | let pre_generated = include_str!("./generated/minimal-reference.adoc");
191 | // Replace the version and date placeholders:
192 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
193 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
194 |
195 | assert_eq!(reference.text, pre_generated);
196 | }
197 |
198 | /// Test that we generate the snippet file that we expect.
199 | #[test]
200 | fn test_minimal_snippet() {
201 | let mod_type = ContentType::Snippet;
202 | let mod_title = "Minimal snippet";
203 | let options = minimal_options();
204 | let snippet = Module::new(mod_type, mod_title, &options);
205 |
206 | let pre_generated = include_str!("./generated/minimal-snippet.adoc");
207 | // Replace the version and date placeholders:
208 | let pre_generated = pre_generated.replace("{{generator_version}}", generator_version());
209 | let pre_generated = pre_generated.replace("{{current_day}}", ¤t_day());
210 |
211 | assert_eq!(snippet.text, pre_generated);
212 | }
213 |
--------------------------------------------------------------------------------