From 32cad125c9b18ef53f6144d2cc85bbebb2a81c3e Mon Sep 17 00:00:00 2001 From: Eugene Kalinin Date: Sun, 8 Nov 2026 00:16:08 +0300 Subject: [PATCH] docs(openspec): archive add-skip-no-markers change --- .../.openspec.yaml | 0 .../2026-11-08-add-skip-no-markers}/design.md | 0 .../proposal.md | 0 .../specs/toc-skip-no-markers/spec.md | 0 .../specs/toc-stdout/spec.md | 0 .../2026-11-08-add-skip-no-markers}/tasks.md | 0 openspec/specs/toc-skip-no-markers/spec.md | 112 ++++++++++++++++++ openspec/specs/toc-stdout/spec.md | 4 +- 8 files changed, 114 insertions(+), 2 deletions(-) rename openspec/changes/{add-skip-no-markers => archive/2026-11-08-add-skip-no-markers}/.openspec.yaml (100%) rename openspec/changes/{add-skip-no-markers => archive/2026-11-08-add-skip-no-markers}/design.md (100%) rename openspec/changes/{add-skip-no-markers => archive/2026-11-08-add-skip-no-markers}/proposal.md (100%) rename openspec/changes/{add-skip-no-markers => archive/2026-11-08-add-skip-no-markers}/specs/toc-skip-no-markers/spec.md (100%) rename openspec/changes/{add-skip-no-markers => archive/2026-11-08-add-skip-no-markers}/specs/toc-stdout/spec.md (100%) rename openspec/changes/{add-skip-no-markers => archive/2026-11-08-add-skip-no-markers}/tasks.md (100%) create mode 100644 openspec/specs/toc-skip-no-markers/spec.md diff --git a/openspec/changes/add-skip-no-markers/.openspec.yaml b/openspec/changes/archive/2026-11-08-add-skip-no-markers/.openspec.yaml similarity index 100% rename from openspec/changes/add-skip-no-markers/.openspec.yaml rename to openspec/changes/archive/2026-11-08-add-skip-no-markers/.openspec.yaml diff --git a/openspec/changes/add-skip-no-markers/design.md b/openspec/changes/archive/2026-11-08-add-skip-no-markers/design.md similarity index 100% rename from openspec/changes/add-skip-no-markers/design.md rename to openspec/changes/archive/2026-11-08-add-skip-no-markers/design.md diff --git a/openspec/changes/add-skip-no-markers/proposal.md b/openspec/changes/archive/2026-11-08-add-skip-no-markers/proposal.md similarity index 100% rename from openspec/changes/add-skip-no-markers/proposal.md rename to openspec/changes/archive/2026-11-08-add-skip-no-markers/proposal.md diff --git a/openspec/changes/add-skip-no-markers/specs/toc-skip-no-markers/spec.md b/openspec/changes/archive/2026-11-08-add-skip-no-markers/specs/toc-skip-no-markers/spec.md similarity index 100% rename from openspec/changes/add-skip-no-markers/specs/toc-skip-no-markers/spec.md rename to openspec/changes/archive/2026-11-08-add-skip-no-markers/specs/toc-skip-no-markers/spec.md diff --git a/openspec/changes/add-skip-no-markers/specs/toc-stdout/spec.md b/openspec/changes/archive/2026-11-08-add-skip-no-markers/specs/toc-stdout/spec.md similarity index 100% rename from openspec/changes/add-skip-no-markers/specs/toc-stdout/spec.md rename to openspec/changes/archive/2026-11-08-add-skip-no-markers/specs/toc-stdout/spec.md diff --git a/openspec/changes/add-skip-no-markers/tasks.md b/openspec/changes/archive/2026-11-08-add-skip-no-markers/tasks.md similarity index 100% rename from openspec/changes/add-skip-no-markers/tasks.md rename to openspec/changes/archive/2026-11-08-add-skip-no-markers/tasks.md diff --git a/openspec/specs/toc-skip-no-markers/spec.md b/openspec/specs/toc-skip-no-markers/spec.md new file mode 100644 index 0000000..8b061f0 --- /dev/null +++ b/openspec/specs/toc-skip-no-markers/spec.md @@ -0,0 +1,112 @@ +# toc-skip-no-markers Specification + +## Purpose + +Lets `--insert` run on many local files, such as all markdown files found by `find`, by +skipping the files without the `` and `` markers instead of stopping +with an error. + +## Requirements + +### Requirement: Skip a file without markers + +With `--skip-no-markers`, a local file SHALL be skipped when it has no line that counts as +the `` marker or no line that counts as the `` marker, as defined in +`toc-markers`. A skipped file SHALL NOT be changed, no backup or TOC files SHALL be +created for it, no request SHALL be sent to the GitHub API for it, and stdout SHALL have +no TOC entries of it. For a skipped file, the program SHALL print +`: Warning: no or in the file, skipped` to stderr, where +`` is the input as given on the command line, also with one input. The other +inputs SHALL be processed as before this change. + +The exit code SHALL be 0 when every local file is skipped. An error of another input, +such as a GitHub API error, SHALL exit with code 1 as before this change. A local input +that is not an existing file, such as a missing path, SHALL NOT be skipped and SHALL give +the same output and exit code as before this change. + +#### Scenario: Several files + +- **WHEN** the user runs + `gh-md-toc --insert --no-backup --hide-footer --skip-no-markers /a.md /b.md /c.md`, + where `a.md` is `\n\n\n# Page a\n`, `b.md` is `# Page b\n`, and + `c.md` is `\n\n\n# Page c\n` +- **THEN** `a.md` is `\n* [Page a](#page-a)\n\n\n# Page a\n`, `c.md` + is `\n* [Page c](#page-c)\n\n\n# Page c\n`, `b.md` does not change, + stdout has the lines `* [Page a](#page-a)` and `* [Page c](#page-c)` and no line + `* [Page b](#page-b)`, stderr is + `/b.md: Warning: no or in the file, skipped`, and the exit + code is 0 + +#### Scenario: One file with one marker + +- **WHEN** the user runs `GH_TOC_TOKEN=invalid gh-md-toc --insert --skip-no-markers /b.md`, + where `` has only `b.md`, and `b.md` is `\n\n# Page b\n` +- **THEN** `b.md` does not change, `` has only `b.md`, stdout has no line + `Parsing local markdown file requires access to github API`, stderr is + `/b.md: Warning: no or in the file, skipped`, and the exit + code is 0 + +#### Scenario: Missing file + +- **WHEN** the user runs `gh-md-toc --skip-no-markers /missing.md`, where + `missing.md` does not exist +- **THEN** stderr has no line that ends with `in the file, skipped`, and the exit code + is 1 + +### Requirement: Turns on --insert + +`--skip-no-markers` SHALL turn on `--insert`, as `--no-backup` and `--hide-footer` do. A +local file with the markers and a remote URL SHALL get the same output and the same +changes as with `--insert` without `--skip-no-markers`. + +`--skip-no-markers` SHALL be accepted after `--indent `, `--depth `, +`--numbered `, `--bullet `, `--insert`, `--no-backup` and `--hide-footer` +(when given) and before `--stdout`, `--skip-header` and the inputs. + +#### Scenario: Without --insert + +- **WHEN** the user runs `gh-md-toc --skip-no-markers /a.md`, where `a.md` is + `\n\n\n# Page a\n` +- **THEN** line 2 of `a.md` is `* [Page a](#page-a)`, stdout has the line + `!! TOC was added into: '/a.md'`, and the exit code is 0 + +### Requirement: Without the option + +Without `--skip-no-markers`, `--insert` on a local file without the markers SHALL print +`You don't have or in your file...exiting` to stdout and exit with +code 1, and the inputs after that file SHALL NOT be processed, as before this change. + +#### Scenario: Several files without the option + +- **WHEN** the user runs + `gh-md-toc --insert --no-backup --hide-footer /a.md /b.md /c.md`, with + the files of the scenario "Several files" +- **THEN** line 2 of `a.md` is `* [Page a](#page-a)`, stdout has the line + `You don't have or in your file...exiting`, `b.md` and `c.md` do + not change, and the exit code is 1 + +### Requirement: Invalid usage with --stdout + +With `--skip-no-markers` and `--stdout`, the program SHALL print +`--skip-no-markers cannot be used with --stdout.` to stderr, print nothing to stdout, and +exit with code 1 before any network call. + +#### Scenario: With --stdout + +- **WHEN** the user runs + `gh-md-toc --skip-no-markers --stdout "tests/test directory/test_stdout.md"` +- **THEN** stderr is `--skip-no-markers cannot be used with --stdout.`, stdout is empty, + and the exit code is 1 + +### Requirement: Help lists the option + +`--help` SHALL list `--skip-no-markers` in the "Options" section right after +`--hide-footer`. + +#### Scenario: Help output + +- **WHEN** the user runs `gh-md-toc --help` +- **THEN** the line after + ` --hide-footer Do not write date & author of the last TOC update. Set --insert as well. Default: false.` + is + ` --skip-no-markers Skip files without or . Set --insert as well. Default: false.` diff --git a/openspec/specs/toc-stdout/spec.md b/openspec/specs/toc-stdout/spec.md index a047c5f..b157c0e 100644 --- a/openspec/specs/toc-stdout/spec.md +++ b/openspec/specs/toc-stdout/spec.md @@ -160,12 +160,12 @@ be kept when it has no newline. ### Requirement: Help lists the option -`--help` SHALL list `--stdout` in the "Options" section right after `--hide-footer`. +`--help` SHALL list `--stdout` in the "Options" section right after `--skip-no-markers`. #### Scenario: Help output - **WHEN** the user runs `gh-md-toc --help` - **THEN** the line after - ` --hide-footer Do not write date & author of the last TOC update. Set --insert as well. Default: false.` + ` --skip-no-markers Skip files without or . Set --insert as well. Default: false.` is ` --stdout Print the whole file with the new TOC to stdout. The file is not changed. Default: false.`