@datalackey/update-markdown-toc 1.0.4 → 1.1.1

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 (2) hide show
  1. package/README.md +38 -17
  2. package/package.json +6 -1
package/README.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # update-markdown-toc
2
2
 
3
+ <p align="center">
4
+ <img
5
+ src="doc/demo.gif"
6
+ width="720"
7
+ alt="update-markdown-toc demo">
8
+ </p>
9
+
10
+
11
+
3
12
  <!-- TOC:START -->
4
13
  - [update-markdown-toc](#update-markdown-toc)
5
14
  - [Introduction](#introduction)
@@ -36,12 +45,11 @@ A Node.js command-line **documentation helper** which automatically:
36
45
 
37
46
  ## Why not Some Other Markdown TOC Generator ?
38
47
 
39
- Most Markdown TOC tools (e.g., [markdown-toc](https://github.com/jonschlinkert/markdown-toc),
48
+ Most Markdown TOC tools (e.g., [markdown-toc](https://github.com/jonschlinkert/markdown-toc),
40
49
  [md-toc-cli](https://github.com/eugene-khyst/md-toc-cli))
41
- operate on a **single file at a time**, a mode which our tool also supports.
42
- But we are aware of no other alternative which supports our tool's main distinguishing feature:
43
- the ability to search for, check and update all Markdown documents within an entire folder hierarchy.
44
-
50
+ operate on a single file at a time, a mode which we also support.
51
+ The primary distinguishing feature of our tool is its ability to recursively search for, check, and update all Markdown documents within an entire folder hierarchy, making it suitable for CI and
52
+ large repositories.
45
53
 
46
54
 
47
55
 
@@ -123,20 +131,17 @@ explicitly. Unlike normal operation, --check does not default to README.md.
123
131
  ## TOC Markers
124
132
 
125
133
  The tool operates only on files containing **both** start and end markers,
126
- as *almost* shown below. Don't use these markers exactly as written. Use brackets ('<' and '>'), and not
127
- squiggley braces (i.e., not '{' and '}'). The reason for this documentation
128
- oddity is that, if we used brackets,
129
- then when we run our tool against this code base we would end up getting an unwanted table of contents below !
134
+ as shown below:
135
+
136
+
137
+ &nbsp;&nbsp;&nbsp; &lt;!-- TOC:START --&gt;<br/>
138
+ &nbsp;&nbsp;&nbsp; &lt;!-- TOC:END --&gt;
130
139
 
131
140
 
132
- ```md
133
- {!-- TOC:START --}
134
- {!-- TOC:END --}
135
- ```
136
141
 
137
142
  Any existing content between the region start and end markers is lost. The new content will be the generated TOC that
138
143
  reflects the section headers marked with '#'s in the Markdown document.
139
-
144
+
140
145
  Content outside the markers is preserved verbatim.
141
146
  If either marker is missing, the tool prints an error message and exits with a non-zero status code.
142
147
 
@@ -148,7 +153,7 @@ If either marker is missing, the tool prints an error message and exits with a n
148
153
  ### As Part of code/test/debug Work Flow
149
154
 
150
155
  To ensure that your code is built afresh, passes tests, and that your documentation TOCs are up to date, you could
151
- use invoke the tool in something akin to the package.json below.
156
+ invoke the tool via something akin to the package.json below.
152
157
  Before commit and push, you would type: 'npm run build'
153
158
 
154
159
 
@@ -206,8 +211,7 @@ the tool operates in strict mode.
206
211
  In this mode, any of the following conditions cause an immediate error and a non-zero exit code:
207
212
 
208
213
  - file does not exist, or cannot be read (e.g. due to permissions).
209
- - file does not contain both TOC delimiters ({!-- TOC:START --} and {!-- TOC:END --}).
210
- (See [TOC markers](#toc-markers) section about how we describe markers in this guide.)
214
+ - file does not contain both TOC delimiters (&lt;!-- TOC:START --&gt; and &nbsp; &lt;!-- TOC:END --&gt;).
211
215
  - file is stale (i.e. the existing TOC differs from the generated TOC).
212
216
  - file contains TOC delimiters but no Markdown headings are found from which a TOC can be generated.
213
217
 
@@ -239,6 +243,23 @@ Updated: docs/guide.md
239
243
  Up-to-date: docs/api.md
240
244
  ```
241
245
 
246
+ ## Design Goals and Philosophy
247
+
248
+ This tool was designed in accordance with the top-level
249
+ [Build Philosophy](../../README.md#build-philosophy) of this repository.
250
+
251
+
252
+ - **update mode** (writes files: this should be run locally by developers, and should never run in CI)
253
+ - **check mode** (validates and exits non-zero if stale: mainly intended to be run in CI -- optional for local use)
254
+
255
+ The intended workflow is:
256
+
257
+ 1. Developers run the update command locally.
258
+ 2. Generated TOC content is reviewed and committed.
259
+ 3. CI runs in `--check` mode to ensure no drift exists.
260
+
261
+
242
262
  ## Guidelines For Project Contributors
243
263
 
244
264
  Contributors to the project should consult [this document](GUIDELINES-FOR-PROJECT-CONTRIBUTORS.md)
265
+
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@datalackey/update-markdown-toc",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "Auto-generate Table of Contents for a Markdown file (or files, recursively from a top level folder)",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
+ "private": false,
8
+ "scripts": {
9
+ "test": "bash scripts/run-all-tests.sh"
10
+ },
7
11
  "bin": {
8
12
  "update-markdown-toc": "./bin/update-markdown-toc.js"
9
13
  },
@@ -17,6 +21,7 @@
17
21
  "build",
18
22
  "automation",
19
23
  "javascript",
24
+ "typescript",
20
25
  "node",
21
26
  "documentation",
22
27
  "readme",