create-asciidoc-multi-book-workspace 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +28 -0
  3. package/dist/create.js +11 -3
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/init-workspace.d.ts +1 -0
  7. package/dist/init-workspace.js +15 -13
  8. package/dist/template-manifest.d.ts +9 -2
  9. package/dist/template-manifest.js +24 -9
  10. package/package.json +1 -1
  11. package/templates/default-workspace/books/07-structured-writing-conventions/backmatter/appendix-a.adoc +6 -0
  12. package/templates/default-workspace/books/07-structured-writing-conventions/backmatter/appendix-b-decision-trees.adoc +32 -2
  13. package/templates/default-workspace/books/07-structured-writing-conventions/backmatter/glossary.adoc +1 -0
  14. package/templates/default-workspace/books/07-structured-writing-conventions/book.adoc +2 -0
  15. package/templates/default-workspace/books/07-structured-writing-conventions/parts/010-source-surface/020-heading-address-and-xref.adoc +1 -1
  16. package/templates/default-workspace/books/07-structured-writing-conventions/parts/020-names-roles-and-relations/020-heading-roles.adoc +2 -0
  17. package/templates/default-workspace/books/07-structured-writing-conventions/parts/020-names-roles-and-relations/030-relation-predicate.adoc +2 -0
  18. package/templates/default-workspace/books/07-structured-writing-conventions/parts/030-fields-and-terminology/010-surface-fields.adoc +25 -1
  19. package/templates/default-workspace/books/07-structured-writing-conventions/parts/030-fields-and-terminology/030-declaring-conventions.adoc +70 -0
  20. package/templates/default-workspace/books/07-structured-writing-conventions/parts/030-fields-and-terminology/_partintro.adoc +1 -1
  21. package/templates/solo-workspace/README.md +24 -0
  22. package/templates/solo-workspace/catalog.adoc +7 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 - 2026-10-21
4
+
5
+ ### Added
6
+
7
+ - Add `--solo` to the `create` command and export `initSoloWorkspace` from the package root: generate a workspace that contains only the structured writing conventions book, shelved as book 01.
8
+ - Add the chapter "声明本书的约定" (declaring the book's conventions) to the structured writing conventions sample: `.convention` headings with `declares=roles|relations|values|fields` write a book's controlled vocabularies in the book itself, so readers, check scripts, and query tools read one source. A `fields` declaration can carry `id-prefix` for roles whose address labels are existing technical addresses.
9
+
10
+ ### Changed
11
+
12
+ - Show in the structured writing conventions sample how a field value attaches a code block or table with `+`, and list every way a description list stops counting as fields: an unattached block, another block between the heading and the list, block attributes on the list, or a nested description list. It also shows how to keep a description list under a heading as body text.
13
+ - State that a heading's role scope is a reading context: projection, checks, and query tools read only the role written on each heading.
14
+ - Add a decision tree for declaring and maintaining conventions, and update the quick reference, glossary, and part introductions.
15
+
3
16
  ## 0.3.1 - 2026-10-15
4
17
 
5
18
  ### Changed
package/README.md CHANGED
@@ -13,6 +13,14 @@ pnpm install
13
13
  pnpm run build
14
14
  ```
15
15
 
16
+ For a workspace with only the structured writing conventions book (shelved as book 01), add `--solo`:
17
+
18
+ ```bash
19
+ pnpm create asciidoc-multi-book-workspace my-book --solo
20
+ ```
21
+
22
+ See [Solo Workspace](#solo-workspace).
23
+
16
24
  npm users can run:
17
25
 
18
26
  ```bash
@@ -36,6 +44,8 @@ console.log(result.targetDir);
36
44
 
37
45
  The host CLI owns command parsing and user-facing output. This package owns the workspace files it creates.
38
46
 
47
+ `initSoloWorkspace` takes the same options and creates the [solo workspace](#solo-workspace).
48
+
39
49
  The generated workspace contains:
40
50
 
41
51
  ```text
@@ -58,6 +68,23 @@ shared/images/workspace-map.svg
58
68
 
59
69
  It does not include this repository's `test/`, `.github/`, `src/`, `dist/`, `DESIGN.adoc`, or maintainer release checks.
60
70
 
71
+ ## Solo Workspace
72
+
73
+ The solo workspace holds one book: sample book `07-structured-writing-conventions`, shelved as
74
+ `books/01-structured-writing-conventions`, with a short catalog and README written for it:
75
+
76
+ ```text
77
+ README.md
78
+ catalog.adoc
79
+ package.json
80
+ .gitignore
81
+ tools/adoc-books.mjs
82
+ books/01-structured-writing-conventions
83
+ shared/attributes.adoc
84
+ ```
85
+
86
+ The other sample books stay in the template and are generated only by the default workspace.
87
+
61
88
  ## Generated Workspace
62
89
 
63
90
  The generated `package.json` directly lists the AsciiDoc toolchain:
@@ -81,6 +108,7 @@ pnpm run clean
81
108
  ```text
82
109
  src/ # TypeScript initializer and user runtime source
83
110
  templates/default-workspace/ # true source for the generated user workspace
111
+ templates/solo-workspace/ # catalog and README written for the solo workspace
84
112
  test/ # maintainer tests
85
113
  DESIGN.adoc # maintainer design specification
86
114
  .github/ # maintainer CI
package/dist/create.js CHANGED
@@ -1,13 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import path from "node:path";
3
- import { initWorkspace } from "./init-workspace.js";
3
+ import { initSoloWorkspace, initWorkspace } from "./init-workspace.js";
4
4
  function usage() {
5
5
  return [
6
6
  "Usage:",
7
- " create-asciidoc-multi-book-workspace <target>",
7
+ " create-asciidoc-multi-book-workspace <target> [--solo] [--force]",
8
+ "",
9
+ "Options:",
10
+ " --solo one book only: the structured writing conventions sample, shelved as",
11
+ " books/01-structured-writing-conventions",
12
+ " --force write into a non-empty target; template output paths are overwritten,",
13
+ " other files are kept",
8
14
  "",
9
15
  "Examples:",
10
16
  " pnpm create asciidoc-multi-book-workspace my-books",
17
+ " pnpm create asciidoc-multi-book-workspace my-book --solo",
11
18
  " npm create asciidoc-multi-book-workspace@latest my-books"
12
19
  ].join("\n");
13
20
  }
@@ -23,7 +30,8 @@ async function main() {
23
30
  process.exitCode = 1;
24
31
  return;
25
32
  }
26
- const result = await initWorkspace({ targetDir: target, force: args.includes("--force") });
33
+ const init = args.includes("--solo") ? initSoloWorkspace : initWorkspace;
34
+ const result = await init({ targetDir: target, force: args.includes("--force") });
27
35
  const displayTarget = path.relative(process.cwd(), result.targetDir) || ".";
28
36
  console.log(`Created AsciiDoc multi-book workspace in ${displayTarget}`);
29
37
  console.log("");
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { initWorkspace } from "./init-workspace.js";
1
+ export { initSoloWorkspace, initWorkspace } from "./init-workspace.js";
2
2
  export type { InitWorkspaceOptions, InitWorkspaceResult } from "./init-workspace.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { initWorkspace } from "./init-workspace.js";
1
+ export { initSoloWorkspace, initWorkspace } from "./init-workspace.js";
@@ -7,3 +7,4 @@ export interface InitWorkspaceResult {
7
7
  packageName: string;
8
8
  }
9
9
  export declare function initWorkspace(options: InitWorkspaceOptions): Promise<InitWorkspaceResult>;
10
+ export declare function initSoloWorkspace(options: InitWorkspaceOptions): Promise<InitWorkspaceResult>;
@@ -1,10 +1,10 @@
1
1
  import { cp, mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { defaultWorkspaceTemplate, templatePackageNamePlaceholder } from "./template-manifest.js";
4
+ import { defaultWorkspaceCopies, packageJsonTemplate, soloWorkspaceCopies, templatePackageNamePlaceholder } from "./template-manifest.js";
5
5
  const sourceDir = path.dirname(fileURLToPath(import.meta.url));
6
6
  const packageRoot = path.resolve(sourceDir, "..");
7
- const templateRoot = path.join(packageRoot, "templates", defaultWorkspaceTemplate);
7
+ const templatesRoot = path.join(packageRoot, "templates");
8
8
  const runtimeScript = path.join(packageRoot, "dist", "runtime", "adoc-books.mjs");
9
9
  async function exists(filePath) {
10
10
  try {
@@ -32,27 +32,29 @@ function safePackageName(rawName) {
32
32
  .replaceAll(/^-+|-+$/g, "");
33
33
  return normalized || "asciidoc-books";
34
34
  }
35
- async function copyTemplatePath(name, targetDir) {
36
- await cp(path.join(templateRoot, name), path.join(targetDir, name), {
37
- force: true,
38
- recursive: true
39
- });
40
- }
41
- export async function initWorkspace(options) {
35
+ async function createWorkspace(options, copies) {
42
36
  const targetDir = path.resolve(options.targetDir);
43
37
  const targetExists = await exists(targetDir);
44
38
  if (targetExists && !options.force && !await isEmptyDirectory(targetDir)) {
45
39
  throw new Error(`target directory is not empty: ${targetDir}`);
46
40
  }
47
41
  await mkdir(targetDir, { recursive: true });
48
- for (const name of ["README.md", "catalog.adoc", "books", "shared"]) {
49
- await copyTemplatePath(name, targetDir);
42
+ for (const { from, to } of copies) {
43
+ await cp(path.join(templatesRoot, from), path.join(targetDir, to), {
44
+ force: true,
45
+ recursive: true
46
+ });
50
47
  }
51
- const packageTemplate = await readFile(path.join(templateRoot, "package.json.template"), "utf8");
48
+ const packageTemplate = await readFile(path.join(templatesRoot, packageJsonTemplate), "utf8");
52
49
  const packageName = safePackageName(path.basename(targetDir));
53
50
  await writeFile(path.join(targetDir, "package.json"), packageTemplate.replaceAll(templatePackageNamePlaceholder, packageName), "utf8");
54
- await writeFile(path.join(targetDir, ".gitignore"), await readFile(path.join(templateRoot, "gitignore.template"), "utf8"), "utf8");
55
51
  await mkdir(path.join(targetDir, "tools"), { recursive: true });
56
52
  await cp(runtimeScript, path.join(targetDir, "tools", "adoc-books.mjs"), { force: true });
57
53
  return { targetDir, packageName };
58
54
  }
55
+ export async function initWorkspace(options) {
56
+ return createWorkspace(options, defaultWorkspaceCopies);
57
+ }
58
+ export async function initSoloWorkspace(options) {
59
+ return createWorkspace(options, soloWorkspaceCopies);
60
+ }
@@ -1,3 +1,10 @@
1
- export declare const defaultWorkspaceTemplate = "default-workspace";
1
+ export interface TemplateCopy {
2
+ /** Path under `templates/`. */
3
+ from: string;
4
+ /** Path inside the generated workspace. */
5
+ to: string;
6
+ }
2
7
  export declare const templatePackageNamePlaceholder = "{{name}}";
3
- export declare const fixedTemplateOutputPaths: readonly ["README.md", "catalog.adoc", "package.json", ".gitignore", "tools/adoc-books.mjs", "books", "shared"];
8
+ export declare const packageJsonTemplate = "default-workspace/package.json.template";
9
+ export declare const defaultWorkspaceCopies: readonly TemplateCopy[];
10
+ export declare const soloWorkspaceCopies: readonly TemplateCopy[];
@@ -1,11 +1,26 @@
1
- export const defaultWorkspaceTemplate = "default-workspace";
2
1
  export const templatePackageNamePlaceholder = "{{name}}";
3
- export const fixedTemplateOutputPaths = [
4
- "README.md",
5
- "catalog.adoc",
6
- "package.json",
7
- ".gitignore",
8
- "tools/adoc-books.mjs",
9
- "books",
10
- "shared"
2
+ // Rendered with the target's package name instead of copied, so it stays outside the copy
3
+ // tables; every workspace shape renders this same file.
4
+ export const packageJsonTemplate = "default-workspace/package.json.template";
5
+ // A copy table is the complete list of template content a workspace shape receives;
6
+ // the initializer adds only the rendered package.json and tools/adoc-books.mjs.
7
+ // `gitignore.template` exists because npm drops `.gitignore` files from published packages.
8
+ export const defaultWorkspaceCopies = [
9
+ { from: "default-workspace/README.md", to: "README.md" },
10
+ { from: "default-workspace/catalog.adoc", to: "catalog.adoc" },
11
+ { from: "default-workspace/books", to: "books" },
12
+ { from: "default-workspace/shared", to: "shared" },
13
+ { from: "default-workspace/gitignore.template", to: ".gitignore" }
14
+ ];
15
+ // One book on its own shelf: sample book 07 is shelved as 01. The catalog and README are
16
+ // written for this shelf; shared/images/ stays behind because only the sample catalog uses it.
17
+ export const soloWorkspaceCopies = [
18
+ { from: "solo-workspace/README.md", to: "README.md" },
19
+ { from: "solo-workspace/catalog.adoc", to: "catalog.adoc" },
20
+ {
21
+ from: "default-workspace/books/07-structured-writing-conventions",
22
+ to: "books/01-structured-writing-conventions"
23
+ },
24
+ { from: "default-workspace/shared/attributes.adoc", to: "shared/attributes.adoc" },
25
+ { from: "default-workspace/gitignore.template", to: ".gitignore" }
11
26
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-asciidoc-multi-book-workspace",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Create a complete AsciiDoc multi-book workspace.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -44,9 +44,15 @@
44
44
  |`[.example, owner=writing-team]`
45
45
  |role 和 named attributes 保留标题的作用与附加字段。
46
46
 
47
+ |`[.convention, declares=roles]`
48
+ |约定声明。标题下的描述列表是本书的 role 词表;`declares` 还可以取 `relations`、`values`(配 `for` 与 `field`)和 `fields`(配 `for`)。
49
+
47
50
  |`summary::` + 下一行说明文本
48
51
  |标题下描述列表字段。用于较多字段或多行字段值。
49
52
 
53
+ |字段文字之后的 `+` + 块
54
+ |把代码块、表格等挂到字段上,块属于字段值。字段之间不插入不带 `+` 的块。
55
+
50
56
  |`pass:[xref:标题[显示文本]]`
51
57
  |显示为链接,投影为 references。
52
58
 
@@ -68,7 +68,8 @@
68
68
  └─ 是:评估语境连续性。
69
69
 
70
70
  2. 当前子标题承载的认知角色是否与父标题声明的 role 相同?
71
- ├─ 是:不重复声明 role;下级标题默认属于同一角色范围。流程结束。
71
+ ├─ 是:写作时可以不重复声明 role,读者按语境理解为同一角色范围。
72
+ │ 工具只读标题自己写下的 role:想让检查核对它的字段、让查询列出它,就自己写上 role。流程结束。
72
73
  └─ 否:从受控词表中选取匹配新语境的 role,显式写入当前标题 attrlist。
73
74
  该声明完成语境切换。流程结束。
74
75
  ----
@@ -116,8 +117,37 @@
116
117
  │ 例如 `[owner=writing-team, status=active]`。流程结束。
117
118
  └─ 字段较多,或包含多行字段值:
118
119
  写入紧随标题下方的第一个连续描述列表。
119
- 例如 `key:: value`。流程结束。
120
+ 例如 `key:: value`。进入块评估。
121
+
122
+ 3. 字段值是否需要附带代码块、表格或另一段正文?
123
+ ├─ 是:在字段文字之后写一行 `+`,再写块;块属于字段值。
124
+ │ 字段之间不插入不带 `+` 的块,否则字段列表在块前结束。流程结束。
125
+ └─ 否:流程结束。
126
+ ----
127
+
128
+ == 约定的声明与维护
129
+
130
+ 触发场景:: 作者为本书引入或修改 role、rel 谓词、字段取值或字段。
131
+
132
+ [source,text]
120
133
  ----
134
+ 1. 本书是否已有对应的约定声明?
135
+ ├─ 是:在该声明的描述列表中增加、修改或删除 term;进入类型评估。
136
+ └─ 否:新建声明标题,放在读者最先读到约定的地方(例如前言里专设一节“本书的书写约定”),
137
+ 写 `[.convention, declares=...]`;进入类型评估。
138
+
139
+ 2. 声明的是什么?
140
+ ├─ role:`declares=roles`。
141
+ ├─ rel 谓词:`declares=relations`。
142
+ ├─ 某个 role 的附加字段取值:`declares=values, for=<role>, field=<字段名>`。
143
+ └─ 某个 role 的标题下描述列表字段:`declares=fields, for=<role>`。
144
+
145
+ 3. term 是否写成写作时使用的那个词?
146
+ ├─ 否:去掉点号与反引号,例如 `.concept` 写成 `concept`;回到本步重新判断。
147
+ └─ 是:在描述中写出这个词的含义。流程结束。
148
+ ----
149
+
150
+ 约定变化时只改声明。检查脚本和查询工具从声明读出词表,不另外维护一份。
121
151
 
122
152
  == 源文件物理编排与编号运算
123
153
 
@@ -16,3 +16,4 @@ relation predicate:: xref `rel` 字段选择的边谓词。
16
16
  source heading:: xref 所在的标题。
17
17
  target heading:: xref selector 指向的标题。
18
18
  surface field:: 源文档表面的附加字段。标题字段可来自标题 attrlist 或标题下描述列表;xref 边字段来自 xref named attributes。
19
+ 约定声明:: 带 `.convention` role 的标题。`declares` 字段说明它声明 role、rel 谓词、字段取值还是字段;标题下的描述列表是词表,term 是词,描述是含义。
@@ -60,6 +60,8 @@ include::parts/030-fields-and-terminology/010-surface-fields.adoc[]
60
60
 
61
61
  include::parts/030-fields-and-terminology/020-glossary.adoc[]
62
62
 
63
+ include::parts/030-fields-and-terminology/030-declaring-conventions.adoc[]
64
+
63
65
  [appendix]
64
66
  include::backmatter/appendix-a.adoc[]
65
67
 
@@ -39,7 +39,7 @@
39
39
  2. 按照书籍结构,跨越 `= 书名`、`= 卷/部`、`== 章` 这些大跨度的指代均需要使用 `xref` 手动标注,平衡隐式上下文的阅读压力。
40
40
  ====
41
41
 
42
- 标题声明角色后,其下级标题默认属于同一角色范围。下级标题可声明不同角色以切换语境。
42
+ 标题声明角色后,其下级标题默认属于同一角色范围。下级标题可声明不同角色以切换语境。角色范围是阅读上的语境;投影、检查和查询工具只读标题自己写下的 role,下级标题不会因此被当作同一 role 的标题核对字段或列出。
43
43
 
44
44
  例如:
45
45
 
@@ -32,4 +32,6 @@ role 写在标题 attrlist 的点号 token 位置。
32
32
 
33
33
  一本书使用的 role 种类和数量,取决于该领域的概念结构。每种 role 的语义在全书中保持唯一。
34
34
 
35
+ 全书的 role 词表写成约定声明,见 xref:declaring-conventions[声明本书的约定]。
36
+
35
37
  读者和工具链可以依据 role 进行导航文本和提取结构。
@@ -13,6 +13,8 @@
13
13
 
14
14
  `rel` 可以被读者和工具当作关系谓词,所以在全书范围内,每种 `rel` 谓词的语义需要保持唯一且不变。
15
15
 
16
+ 全书采用的 rel 谓词写成约定声明,见 xref:declaring-conventions[声明本书的约定]。下面列出常用的几种:
17
+
16
18
  [horizontal]
17
19
  depends-on:: 当前标题的判断、规则或操作以目标标题为依据。阅读顺序和先读建议使用普通 xref 表达。
18
20
  illustrates:: 当前标题提供目标标题的示例。
@@ -30,7 +30,31 @@ summary::
30
30
  示例规则正文从这里开始。
31
31
  ----
32
32
 
33
- `priority:: normal` 和 `summary::` 属于 `示例规则` 标题的附加字段。投影时它们成为标题字段,例如 `aat:priority` 和 `aat:summary`。
33
+ `priority:: normal` 和 `summary::` 属于 `示例规则` 标题的附加字段。投影时它们成为标题字段,例如 `aat:priority` 和 `aat:summary`;`情况` 这样不是 ASCII 标识符的字段名投影为 `aat:field-` 加百分号编码。
34
+
35
+ 字段值需要附带代码块、表格或另一段正文时,用 `+` 把块挂到字段上。挂上来的块属于这个字段的值。
36
+
37
+ [source,asciidoc]
38
+ ------
39
+ [.rule, verdict=adapt]
40
+ == 关闭标签
41
+
42
+ 情况:: 关闭当前标签。
43
+ 规则:: 先结束输入法的组字,再关闭。
44
+ 出处:: `editorCommands.ts:835-839`。
45
+ +
46
+ [source,ts]
47
+ ----
48
+ closeActiveEditor()
49
+ ----
50
+ 判定:: 改写。
51
+ ------
52
+
53
+ `出处` 的值是出处那一行文字和挂上来的代码块。字段值按作者写下的原文保存:反引号、xref 和 include 指令都保留原样。
54
+
55
+ 没有 `+` 的块不属于字段。字段列表在那个块之前结束,块和它之后的内容都是标题的正文;块之后再写的描述列表也不再是字段。字段之间需要代码时,用 `+` 挂上,不要直接插入代码块。
56
+
57
+ 另有三种写法让整串描述列表都不算字段,标题一个字段也得不到:标题与描述列表之间有别的块(段落、提示块、代码块、图片等);描述列表带 style(如 `[horizontal]`)、ID、块标题或其他块属性;某个条目里嵌套了描述列表。这时描述列表是标题的正文。反过来,要让标题正下方的描述列表是正文而不是字段,就在它前面放一段导语,或给它加 `[horizontal]` 等 style。
34
58
 
35
59
  字段名和字段值来自本书自己的约定。同一本书使用附加字段时,应保持字段写法和字段含义稳定。
36
60
 
@@ -0,0 +1,70 @@
1
+ [#declaring-conventions]
2
+ == 声明本书的约定
3
+
4
+ 一本书采用的 role、rel、字段取值和字段构成它的约定。约定写在书里:读者从这里知道每个词的含义,检查脚本和查询工具从同一处读出受控词表。词表只写这一处,书和工具不会各说各的。
5
+
6
+ 声明约定的标题带 `.convention` role 和 `declares` 字段。声明的内容写成标题下的第一个连续描述列表:每个 term 是一个词,描述是这个词的含义。
7
+
8
+ [source,asciidoc]
9
+ ----
10
+ [.convention, declares=roles]
11
+ === 标题的 role
12
+
13
+ concept:: 概念:本书使用的一个词及其含义。
14
+ rule:: 规则:一条可检查的写法规定。
15
+ example:: 示例:用一个具体场景说明抽象判断。
16
+ convention:: 约定:声明本书的 role、rel、字段取值或字段。
17
+
18
+ [.convention, declares=relations]
19
+ === 关系谓词
20
+
21
+ depends-on:: 当前标题的判断、规则或操作以目标标题为依据。
22
+ illustrates:: 当前标题提供目标标题的示例。
23
+ ----
24
+
25
+ `declares` 的取值说明描述列表里的 term 是什么:
26
+
27
+ [horizontal]
28
+ roles:: role 名称。写作时用在 `[.concept]` 的位置。
29
+ relations:: rel 谓词。写作时用在 `rel=depends-on` 的位置。
30
+ values:: 某个 role 的某个附加字段允许的取值。`for` 写这个 role,`field` 写字段名。
31
+ fields:: 某个 role 的标题下描述列表要写出的字段。`for` 写这个 role。这个 role 的标题带显式寻址标签、标签本身又是已有的技术地址时(例如规则的标签同时是测试的名字),可以再写 `id-prefix`,规定标签的开头,例如 `id-prefix=rule-`;一旦写了,这个 role 的每个标题都要写出以它开头的标签。
32
+
33
+ 字段取值和字段用同样的写法声明:
34
+
35
+ [source,asciidoc]
36
+ ----
37
+ [.convention, declares=values, for=rule, field=verdict]
38
+ ==== 规则的判定
39
+
40
+ adopt:: 照搬:理由成立,形式也照搬。
41
+ adapt:: 改写:理由成立,形式换成本项目更顺手的写法。
42
+ skip:: 不搬:只服务于原来的处境。
43
+
44
+ [.convention, declares=fields, for=rule]
45
+ ==== 规则的格式
46
+
47
+ 情况:: 在什么情况下。
48
+ 规则:: 发生什么。
49
+ 出处:: 依据的源文件与行号。
50
+ ----
51
+
52
+ `规则的判定` 说明:带 `.rule` 的标题写 `verdict` 字段,取值是 `adopt`、`adapt` 或 `skip`。`规则的格式` 说明:带 `.rule` 的标题,标题下的描述列表写出 `情况`、`规则` 和 `出处`。xref:surface-fields[附加字段] 中的 `关闭标签` 就是一条符合这两项声明的规则;它多写的 `判定` 字段不在声明里,声明只规定必须写出的字段。
53
+
54
+ 声明的写法:
55
+
56
+ * term 写词本身:写 `concept`,不写 `.concept`,也不加反引号。term 就是写作时使用的那个词。
57
+ * 声明的描述列表紧跟在声明标题之下,与标题之间没有别的块(段落、提示块、图片等);它不带 `[horizontal]` 等 style,也不带 ID、块标题或其他块属性,条目里不嵌套描述列表。违反任何一条,整串描述列表都是正文,声明标题读不出任何词。导语写在上一级标题里。
58
+ * 一个声明标题只声明一种内容。同一个 role 的取值和字段分开声明。
59
+ * `convention` 本身也写进 role 词表,因为声明标题使用这个 role。
60
+
61
+ 声明通常放在读者最先读到约定的地方,例如前言里的“本书的书写约定”一节;某个 role 的格式也可以放在最先使用这个 role 的部分。工具按 `.convention` role 找到声明,不依赖位置。
62
+
63
+ 检查脚本读出声明以后,对每个带 role 的标题核对,不论它写没写寻址标签:
64
+
65
+ * role 在 role 词表中。
66
+ * `declares=values` 声明的字段写了,取值在列表中。没有声明的附加字段(如 `owner`)不受约束;`.convention` 标题例外,它只带 `declares`、`for`、`field` 和 `id-prefix`。
67
+ * `declares=fields` 声明的字段全部写出。
68
+ * 声明了 `id-prefix` 时,标题写出寻址标签,标签以它开头。
69
+
70
+ 正文中的每个 xref,若带 `rel`,谓词在关系谓词词表中。约定变化时只改声明,检查跟着变。
@@ -1 +1 @@
1
- 字段补充标题与引用已经表达的内容;术语表统一全书采用的名称。
1
+ 字段补充标题与引用已经表达的内容;术语表统一全书采用的名称;约定声明把本书的 role、rel 和字段写成工具可读的词表。
@@ -0,0 +1,24 @@
1
+ # My Books
2
+
3
+ An AsciiDoc multi-book workspace that starts with one book: `books/01-structured-writing-conventions`.
4
+
5
+ ## Commands
6
+
7
+ ```bash
8
+ pnpm install
9
+ pnpm run build # writes build/html/index.html
10
+ pnpm run check # checks the catalog, books, xrefs, anchors, and local HTML resources
11
+ pnpm run clean # removes build/
12
+ ```
13
+
14
+ To fetch diagram images into the local HTML output instead of linking Kroki URLs:
15
+
16
+ ```bash
17
+ ADOC_BOOKS_FETCH_DIAGRAMS=1 pnpm run build
18
+ ```
19
+
20
+ ## Add A Book
21
+
22
+ Copy `books/01-structured-writing-conventions` to `books/<NN-book-id>`, edit its `book.adoc`, then add an
23
+ `xref:books/<NN-book-id>/book.adoc[...]` line to `catalog.adoc`.
24
+ `pnpm run check` fails until `catalog.adoc` and `books/` list the same books.
@@ -0,0 +1,7 @@
1
+ = AsciiDoc 书架
2
+ :idprefix:
3
+ :idseparator: -
4
+
5
+ == 书目
6
+
7
+ * xref:books/01-structured-writing-conventions/book.adoc[01 结构化书写约定标本]:标题、引用、role、xref、rel 和附加字段的结构化写法。