llm-docs-builder 1.0.0 → 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.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +2 -0
- data/.github/workflows/ci.yml +10 -4
- data/.github/workflows/docker.yml +5 -5
- data/.github/workflows/push.yml +2 -2
- data/.github/workflows/verify-action-pins.yml +23 -0
- data/.rubocop.yml +9 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +59 -6
- data/Dockerfile +2 -2
- data/Gemfile.lock +27 -25
- data/README.md +41 -17
- data/lib/llm_docs_builder/bulk_transformer.rb +16 -31
- data/lib/llm_docs_builder/cli.rb +86 -78
- data/lib/llm_docs_builder/config.rb +23 -2
- data/lib/llm_docs_builder/generator.rb +78 -72
- data/lib/llm_docs_builder/markdown_finder.rb +120 -0
- data/lib/llm_docs_builder/markdown_transformer.rb +11 -10
- data/lib/llm_docs_builder/output_formatter.rb +1 -1
- data/lib/llm_docs_builder/text_compressor.rb +50 -42
- data/lib/llm_docs_builder/transformers/code_blocks.rb +226 -0
- data/lib/llm_docs_builder/transformers/content_cleanup_transformer.rb +93 -25
- data/lib/llm_docs_builder/transformers/heading_transformer.rb +1 -1
- data/lib/llm_docs_builder/transformers/link_transformer.rb +200 -29
- data/lib/llm_docs_builder/version.rb +1 -1
- data/lib/llm_docs_builder.rb +22 -6
- data/llm-docs-builder.yml.example +7 -5
- data/package-lock.json +15 -40
- data/package.json +1 -1
- data/renovate.json +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 924dcb07f4f13389791b2667f921ee7a4c4b1528f0177947e322e60590a10ae4
|
|
4
|
+
data.tar.gz: bbb45ad93c3691b89ad5ebbe8bd445ae8aeaf28014965403bcd1453cef64cd35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42cf1209d78964b9efdc66969c2085ec403b92493af1f93628280b77965c23acff5131d126bdd5d210eab0fb9484b4c71f7836d5547754650443133dafa161a3
|
|
7
|
+
data.tar.gz: ed64b63741192464c38db29a107bf10b4f1fa3089842839cc0f1f0eecb3410b6724a1281c02e1aab7f92e75a18eac7df12bfcb847588cf245780cae7fe8e01b0
|
data/.github/CODEOWNERS
ADDED
data/.github/workflows/ci.yml
CHANGED
|
@@ -19,10 +19,12 @@ jobs:
|
|
|
19
19
|
specs:
|
|
20
20
|
timeout-minutes: 15
|
|
21
21
|
runs-on: ubuntu-latest
|
|
22
|
+
continue-on-error: ${{ contains(matrix.ruby, 'preview') || contains(matrix.ruby, 'rc') }}
|
|
22
23
|
strategy:
|
|
23
24
|
fail-fast: false
|
|
24
25
|
matrix:
|
|
25
26
|
ruby:
|
|
27
|
+
- '4.1.0-preview1'
|
|
26
28
|
- '4.0'
|
|
27
29
|
- '3.4'
|
|
28
30
|
- '3.3'
|
|
@@ -34,8 +36,12 @@ jobs:
|
|
|
34
36
|
with:
|
|
35
37
|
fetch-depth: 0
|
|
36
38
|
|
|
39
|
+
- name: Remove Gemfile.lock for Ruby preview versions
|
|
40
|
+
if: contains(matrix.ruby, 'preview') || contains(matrix.ruby, 'rc')
|
|
41
|
+
run: rm -f Gemfile.lock
|
|
42
|
+
|
|
37
43
|
- name: Set up Ruby
|
|
38
|
-
uses: ruby/setup-ruby@
|
|
44
|
+
uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
|
|
39
45
|
with:
|
|
40
46
|
ruby-version: ${{ matrix.ruby }}
|
|
41
47
|
bundler-cache: true
|
|
@@ -60,9 +66,9 @@ jobs:
|
|
|
60
66
|
steps:
|
|
61
67
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
62
68
|
- name: Set up Ruby
|
|
63
|
-
uses: ruby/setup-ruby@
|
|
69
|
+
uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
|
|
64
70
|
with:
|
|
65
|
-
ruby-version: '4.0.
|
|
71
|
+
ruby-version: '4.0.10'
|
|
66
72
|
bundler-cache: true
|
|
67
73
|
- name: Run yard-lint
|
|
68
74
|
run: bundle exec yard-lint lib/
|
|
@@ -75,7 +81,7 @@ jobs:
|
|
|
75
81
|
with:
|
|
76
82
|
fetch-depth: 0
|
|
77
83
|
- name: Set up Node.js
|
|
78
|
-
uses: actions/setup-node@
|
|
84
|
+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
79
85
|
with:
|
|
80
86
|
node-version: '20'
|
|
81
87
|
cache: 'npm'
|
|
@@ -45,28 +45,28 @@ jobs:
|
|
|
45
45
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
46
46
|
|
|
47
47
|
- name: Set up QEMU
|
|
48
|
-
uses: docker/setup-qemu-action@
|
|
48
|
+
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4
|
|
49
49
|
|
|
50
50
|
- name: Set up Docker Buildx
|
|
51
|
-
uses: docker/setup-buildx-action@
|
|
51
|
+
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
|
|
52
52
|
|
|
53
53
|
- name: Login to Docker Hub
|
|
54
54
|
if: github.event_name != 'pull_request'
|
|
55
|
-
uses: docker/login-action@
|
|
55
|
+
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
|
|
56
56
|
with:
|
|
57
57
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
58
58
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
59
59
|
|
|
60
60
|
- name: Login to GitHub Container Registry
|
|
61
61
|
if: github.event_name != 'pull_request'
|
|
62
|
-
uses: docker/login-action@
|
|
62
|
+
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
|
|
63
63
|
with:
|
|
64
64
|
registry: ghcr.io
|
|
65
65
|
username: ${{ github.actor }}
|
|
66
66
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
67
67
|
|
|
68
68
|
- name: Build and push
|
|
69
|
-
uses: docker/build-push-action@
|
|
69
|
+
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
|
|
70
70
|
with:
|
|
71
71
|
context: .
|
|
72
72
|
platforms: linux/amd64,linux/arm64
|
data/.github/workflows/push.yml
CHANGED
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
fetch-depth: 0
|
|
25
25
|
|
|
26
26
|
- name: Set up Ruby
|
|
27
|
-
uses: ruby/setup-ruby@
|
|
27
|
+
uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
|
|
28
28
|
with:
|
|
29
29
|
bundler-cache: false
|
|
30
30
|
|
|
@@ -32,4 +32,4 @@ jobs:
|
|
|
32
32
|
run: |
|
|
33
33
|
bundle install --jobs 4 --retry 3
|
|
34
34
|
|
|
35
|
-
- uses: rubygems/release-gem@
|
|
35
|
+
- uses: rubygems/release-gem@2654a0fe0dc39725c07fe84d7fe863a084f2424e # v1.5.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Verify Action Pins
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
paths:
|
|
5
|
+
- '.github/workflows/**'
|
|
6
|
+
jobs:
|
|
7
|
+
verify_action_pins:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
11
|
+
- name: Check SHA pins
|
|
12
|
+
run: |
|
|
13
|
+
# Every remote action must be pinned to a full 40-character commit SHA. Local actions
|
|
14
|
+
# (./) and docker:// images are not checked.
|
|
15
|
+
unpinned=$(grep -E -rn --include="*.yml" --include="*.yaml" \
|
|
16
|
+
"^[[:space:]]*(-[[:space:]]+)?uses:[[:space:]]*['\"]?[^.'\"[:space:]]" .github/workflows/ \
|
|
17
|
+
| grep -Ev "uses:[[:space:]]*['\"]?docker://" \
|
|
18
|
+
| grep -Ev "@[0-9a-f]{40}['\"]?([[:space:]]|$)" || true)
|
|
19
|
+
if [ -n "$unpinned" ]; then
|
|
20
|
+
echo "$unpinned"
|
|
21
|
+
echo "::error::Actions should use SHA pins, not tags or branch names"
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
data/.rubocop.yml
CHANGED
|
@@ -18,6 +18,10 @@ Metrics/ClassLength:
|
|
|
18
18
|
Metrics/MethodLength:
|
|
19
19
|
Max: 35
|
|
20
20
|
|
|
21
|
+
Metrics/ModuleLength:
|
|
22
|
+
Exclude:
|
|
23
|
+
- 'lib/llm_docs_builder/transformers/code_blocks.rb'
|
|
24
|
+
|
|
21
25
|
Metrics/AbcSize:
|
|
22
26
|
Max: 40
|
|
23
27
|
|
|
@@ -40,6 +44,11 @@ Style/MultilineBlockChain:
|
|
|
40
44
|
Exclude:
|
|
41
45
|
- 'spec/**/*'
|
|
42
46
|
|
|
47
|
+
# CLI errors must reach stderr even with warnings disabled (-W0), which silences warn
|
|
48
|
+
Style/StderrPuts:
|
|
49
|
+
Exclude:
|
|
50
|
+
- 'lib/llm_docs_builder/cli.rb'
|
|
51
|
+
|
|
43
52
|
# Disable predicate method naming rule
|
|
44
53
|
Naming/PredicateMethod:
|
|
45
54
|
Enabled: false
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.0.
|
|
1
|
+
4.0.10
|
data/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,84 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.1.1 (2026-12-03)
|
|
4
|
+
- [Fix] **`bulk-transform` Resolves Relative Links From `base_url` Again** - 1.1.0 made `bulk-transform` resolve relative links from each file's directory, so sites that keep each page in `<Page>/index.md` with links written relative to the docs root got every link nested under the page (`<base_url>/Getting-Started/Kafka-Setup` instead of `<base_url>/Kafka-Setup`), which return 404. The default is back to resolving from `base_url`, as before 1.1.0.
|
|
5
|
+
- Set `relative_links: file` to keep the 1.1.0 behavior (links and query-only links resolve from each file's directory). Any value other than `base_url` or `file` fails with `Invalid relative_links: <value> (use base_url or file)`.
|
|
6
|
+
- [Fix] **`transform` No Longer Overwrites the Generated `llms.txt`** - `transform` writes a file only when `-o/--output` is given, and prints to stdout otherwise. Before, it wrote to the config's `output` (the `generate` target, e.g. `public/llms.txt`), and `-o llms.txt` printed to stdout instead of writing the file.
|
|
7
|
+
- If you relied on the config's `output` for `transform`, pass `-o` instead.
|
|
8
|
+
- [Fix] **Compression Options Keep Code Unchanged** - `remove_duplicates` and `remove_stopwords` no longer edit fenced code, indented code or inline code.
|
|
9
|
+
- `remove_duplicates` no longer drops the last lines and the closing fence of a code block that ends like an earlier one, so the rest of the document no longer turns into code.
|
|
10
|
+
- `remove_stopwords` also keeps `~~~` and indented code blocks and bare URLs (`https://example.com/how-to/use-the-api`) unchanged.
|
|
11
|
+
- `remove_duplicates` keeps repeated paragraphs that hold inline code.
|
|
12
|
+
- `normalize_headings` skips every code block the other options detect, so a `#` line in a ```` block that holds a ``` line no longer counts as a heading.
|
|
13
|
+
- [Fix] **Cleanup Options Keep Code Unchanged** - `remove_comments`, `remove_badges`, `remove_images` and `remove_blockquotes` no longer edit fenced code, indented code or inline code, so HTML and Markdown examples stay intact. With `remove_blockquotes`, code inside a blockquote loses its quote markers like the text around it.
|
|
14
|
+
- [Fix] **Missing `--config` File Fails the Run** - `generate`, `transform` and `bulk-transform` now exit 1 with `Config file not found: <path>` when the file given with `--config` does not exist, and write nothing. Before, they ran with the defaults (`docs: .`), so `bulk-transform` wrote `*.llm.md` next to every Markdown file under the current directory. Without `--config`, a missing `llm-docs-builder.yml` still means the defaults. `Config.new` with a missing file is unchanged.
|
|
15
|
+
- [Fix] **CLI Errors Go to stderr** - Error messages are now printed to stderr instead of stdout, so `transform -d missing.md > out.md` no longer writes the error into `out.md`. The `validate` report ("Invalid llms.txt file" and its errors) stays on stdout, as the command's result. Only CLI output changes, not the Ruby API.
|
|
16
|
+
- [Fix] **Unknown Options Are Usage Errors** - An unknown option (e.g. `transform --foo`) now prints `Error: invalid option: --foo` and a pointer to `--help` instead of `Unexpected error: ...`.
|
|
17
|
+
- [Fix] **`parse` Prints Its Summary Without `--verbose`** - `parse` now always prints the title, description and link counts; `--verbose` also lists each link.
|
|
18
|
+
- [Fix] **`transform --output` Ends the File With a Newline** - The output file now ends with `\n`; one is added only if the content lacks it.
|
|
19
|
+
- [Fix] **`--config` No Longer Mixes In `llm-docs-builder.yml`** - With `--config other.yml`, keys that `other.yml` leaves out (`title`, `description`, `base_url`, `body`, `custom_instruction`) are no longer taken from `llm-docs-builder.yml` in the current directory. The config is now loaded once.
|
|
20
|
+
- [Fix] **`remove_code_examples` No Longer Truncates Documents** - The first line indented by four spaces or a tab no longer deletes everything after it. Only indented code blocks are removed; nested list items and list continuation lines stay.
|
|
21
|
+
- A heading or a fence that is not indented now ends a list, so indented code after it counts as code. `base_url` and `convert_urls` no longer rewrite links in such code either.
|
|
22
|
+
- [Fix] **`parse` and `validate` Read `llms.txt` by Default** - Without `--docs`, both commands now read `llms.txt` in the current directory, as documented. Before, they took the config's `docs` setting (the docs directory for `generate`, `.` by default) and failed with "Is a directory".
|
|
23
|
+
- [Fix] **`bulk-transform` Skips Nested Excludes and Hidden Directories** - `bulk-transform` now picks files like `generate` does.
|
|
24
|
+
- A trailing `/**` in `excludes` matches files at any depth (`**/private/**` now skips `private/sub/b.md`), and patterns also match the path relative to the docs directory.
|
|
25
|
+
- Hidden directories (e.g. `.github/`) are skipped unless `include_hidden` is set, as documented in 0.9.4.
|
|
26
|
+
- [Fix] **llms.txt Sections Match the Documented Priorities** - `generate` now sorts pages into sections as the README describes.
|
|
27
|
+
- Pages that match no rule (e.g. `configuration.md`, `install.md`) go to `Documentation` (`priority:medium`) instead of `Optional` (`priority:low`).
|
|
28
|
+
- API docs (`api.md`) go to `Documentation` instead of `Examples`.
|
|
29
|
+
- Example files (`examples.md`) go to `Examples`.
|
|
30
|
+
- Only reference and advanced pages (`reference.md`, `advanced.md`) stay in `Optional`.
|
|
31
|
+
|
|
32
|
+
## 1.1.0 (2026-11-02)
|
|
33
|
+
- [Enhancement] **Relative Link Resolution** - `base_url` link expansion now resolves relative links like a browser would.
|
|
34
|
+
- `../` and `./` segments are normalized (`../other.md` → `https://example.com/other.md` instead of `https://example.com/docs/../other.md`).
|
|
35
|
+
- `bulk-transform` resolves each link from its file's own directory, so `./setup.md` in `guides/intro.md` expands to `<base_url>/guides/setup.md`.
|
|
36
|
+
- Links starting with `/` resolve from `base_url`; anchors, query strings, absolute URLs and `mailto:`/`tel:`/`ftp:` links are unchanged.
|
|
37
|
+
- [Fix] **llms.txt Paths Are Percent-Encoded** - `generate` now percent-encodes each path segment in `llms.txt` entries, with and without `base_url`.
|
|
38
|
+
- `docs/my docs/a b.md` gives `my%20docs/a%20b.md`, so names with spaces or parentheses no longer break the Markdown link.
|
|
39
|
+
- Non-ASCII names are encoded as UTF-8 (`zażółć.md` → `za%C5%BC%C3%B3%C5%82%C4%87.md`).
|
|
40
|
+
- [Fix] **llms.txt Descriptions** - A page description is now always a single line, and the 200-character limit no longer cuts a Markdown link or image in half; a link or image that does not fit is left out.
|
|
41
|
+
- [Fix] **Transformed Files Picked Up as Sources** - `bulk-transform` and `generate` now skip files ending with the transform suffix (`*.llm.md` by default, or `*<suffix>.md`).
|
|
42
|
+
- A second `bulk-transform` run no longer writes `*.llm.llm.md` files.
|
|
43
|
+
- `generate` lists each page once, from its source file, instead of listing both `README.md` and `README.llm.md`.
|
|
44
|
+
- Source files whose names end with the suffix (e.g. `notes.llm.md`) are skipped too. An empty suffix skips nothing.
|
|
45
|
+
- [Fix] **Angle-Bracket Link Destinations** - `base_url` link expansion now resolves CommonMark `[text](<path with spaces>)` links like other relative links: the brackets are dropped and spaces are percent-encoded (`<../my docs/a b.md>` → `<base_url>/my%20docs/a%20b.md`) instead of producing a broken URL with a stray `>`.
|
|
46
|
+
- [Fix] **Query-Only Links** - `base_url` link expansion now resolves a query-only link like `[q](?tab=2)` to the current page (`guides/sub/page.md` gives `<base_url>/guides/sub/page.md?tab=2`, as RFC 3986 does) instead of the page's directory (`<base_url>/guides/sub/?tab=2`). Anchor-only links like `#self` are unchanged.
|
|
47
|
+
- [Fix] **`simplify_links` Strips Only One Prefix** - repeated filler prefixes are now all removed, so `Click here to see the docs` becomes `docs` (as documented) instead of `see the`.
|
|
48
|
+
- [Fix] **Links Inside Code Are Rewritten** - link transformations (`base_url` expansion, `convert_urls`, `simplify_links`) no longer change links in fenced code blocks, indented code blocks and inline code spans.
|
|
49
|
+
- [Fix] **`convert_urls` Skips Anchors, Queries and Relative Links** - `.html`/`.htm` URLs followed by an anchor or a query are now converted (`doc.html#sec` → `doc.md#sec`, `doc.html?x=1` → `doc.md?x=1`).
|
|
50
|
+
- Relative link targets are converted too, also without `base_url` (`[Intro](../intro.html)` → `[Intro](../intro.md)`).
|
|
51
|
+
- `.html` inside a query or an anchor and targets with a non-HTTP scheme (`mailto:`, `ftp:`, `sftp:`, `file:`, ...) are left unchanged.
|
|
52
|
+
- [Fix] **Links With Brackets in Their Text** - `base_url` link expansion now expands links whose text holds brackets, nested up to two levels deep (`[a [b] c](../intro.md)`), and linked images like `[](../intro.md)`, where both the image and the outer link are now expanded. Before, such links stayed relative, and a linked image got only its image expanded.
|
|
53
|
+
- [Fix] **Links With Any URI Scheme** - `base_url` link expansion now leaves every link with a URI scheme unchanged, in any case (`HTTPS://`, `Mailto:`, `sftp:`, `ssh:`, `git:`, `irc:`, `urn:`, `data:`, `javascript:`, ...). Before, only lowercase `http`, `https`, `mailto`, `ftp` and `tel` links were kept, and others became broken URLs like `<base_url>/guides/sftp:/host/x`.
|
|
54
|
+
- [Fix] **Link Reference Definitions** - `base_url` link expansion now expands reference-style link definitions (`[id]: ../intro.md "Title"`) like inline links, so `[text][id]`, `[id][]` and `[id]` links no longer stay relative while inline links in the same file are expanded. Titles are kept; definitions with a URI scheme, anchors, footnotes (`[^1]: ...`) and definitions in code are unchanged.
|
|
55
|
+
- `convert_urls` converts `.html`/`.htm` definition targets too (`[id]: ../intro.html` → `[id]: ../intro.md`).
|
|
56
|
+
- [Fix] **`compare` Web Server Link** - The "Configure your web server" link in the `compare` output now points at the README section "Serving Optimized Docs to AI Bots" (`#serving-optimized-docs-to-ai-bots`) instead of a missing `#serving-optimized-docs` anchor.
|
|
4
57
|
|
|
5
58
|
## 1.0.0 (2026-08-24)
|
|
6
|
-
- [Fix] **Link Expansion Corrupts Non-HTTP URI Schemes**
|
|
59
|
+
- [Fix] **Link Expansion Corrupts Non-HTTP URI Schemes** - `LinkTransformer#expand_relative_links` no longer rewrites `mailto:`, `tel:`, and `ftp:` links into dead `https://...` URLs when `base_url` is set (#165).
|
|
7
60
|
- Any link whose scheme is in the known absolute-scheme list (`http`, `https`, `mailto`, `ftp`, `tel`) is now left untouched, matching `HtmlToMarkdownConverter`'s `SAFE_URI_SCHEMES`.
|
|
8
61
|
- Relative links (e.g. `./guide.md`) continue to expand as before.
|
|
9
62
|
- [Enhancement] Add Ruby warning category opt-in to test helpers
|
|
10
63
|
|
|
11
64
|
## 0.13.0 (2026-05-11)
|
|
12
65
|
- [Breaking] Dropped Ruby 3.2 support. Minimum required Ruby version is now 3.3.
|
|
13
|
-
- [Fix] **Heading Nesting in Normalize Mode**
|
|
66
|
+
- [Fix] **Heading Nesting in Normalize Mode** - Fixed `normalize_headings` producing incorrect heading levels when same-level headings are nested under a parent.
|
|
14
67
|
- Consecutive same-level headings (e.g., two `##` headings) now correctly adjust the child's markdown level to be deeper than the parent's (e.g., `##` → `###`)
|
|
15
68
|
- Effective level formula: `max(parent_effective_level + 1, original_level)`
|
|
16
69
|
- ATX closing hashes (`## Title ##`) are now stripped from titles before building hierarchical paths
|
|
17
|
-
- [Fix] **HTML-to-Markdown Section Nesting**
|
|
70
|
+
- [Fix] **HTML-to-Markdown Section Nesting** - Headings inside nested `<section>` elements now receive adjusted markdown levels based on section nesting depth.
|
|
18
71
|
- `<h2>` inside a nested `<section>` under another `<section>` with its own `<h2>` is now correctly rendered as `###` instead of `##`
|
|
19
72
|
|
|
20
73
|
## 0.12.0 (2025-11-12)
|
|
21
|
-
- [Feature] **HTML to Markdown Reverse Converter**
|
|
74
|
+
- [Feature] **HTML to Markdown Reverse Converter** - Added support for converting HTML content to markdown format.
|
|
22
75
|
- Enables processing of HTML documentation sources
|
|
23
76
|
- Integrates seamlessly with the transformer pipeline
|
|
24
77
|
- Useful for converting web-based docs to markdown for further processing
|
|
25
78
|
- By @Eric-Guo in PR #32.
|
|
26
79
|
|
|
27
80
|
## 0.11.0 (2025-11-03)
|
|
28
|
-
- [Feature] **Transform from URL**
|
|
81
|
+
- [Feature] **Transform from URL** - The `transform` command now accepts a remote URL via `--url` and processes fetched content through the standard transformer pipeline.
|
|
29
82
|
- Example: `llm-docs-builder transform --url https://example.com/docs/page.html`
|
|
30
83
|
- Applies all configured transformations and output options identically to local files
|
|
31
84
|
- By @Eric-Guo and @codex in PR #28.
|
data/Dockerfile
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Creates a minimal Docker image (~50MB) for running the CLI without Ruby installation
|
|
5
5
|
|
|
6
6
|
# Stage 1: Builder
|
|
7
|
-
FROM ruby:4.0-alpine AS builder
|
|
7
|
+
FROM ruby:4.0.10-alpine AS builder
|
|
8
8
|
|
|
9
9
|
# Install build dependencies
|
|
10
10
|
RUN apk add --no-cache \
|
|
@@ -36,7 +36,7 @@ RUN bundle config set --local without 'development test' && \
|
|
|
36
36
|
RUN gem build llm-docs-builder.gemspec
|
|
37
37
|
|
|
38
38
|
# Stage 2: Runtime
|
|
39
|
-
FROM ruby:4.0-alpine
|
|
39
|
+
FROM ruby:4.0.10-alpine
|
|
40
40
|
|
|
41
41
|
# Install runtime dependencies and build tools for native extensions
|
|
42
42
|
RUN apk add --no-cache \
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
llm-docs-builder (1.
|
|
4
|
+
llm-docs-builder (1.1.1)
|
|
5
5
|
nokogiri (~> 1.17)
|
|
6
6
|
zeitwerk (~> 2.6)
|
|
7
7
|
|
|
@@ -11,65 +11,67 @@ GEM
|
|
|
11
11
|
ast (2.4.3)
|
|
12
12
|
coderay (1.1.3)
|
|
13
13
|
diff-lcs (1.6.2)
|
|
14
|
-
io-console (0.9.
|
|
15
|
-
json (2.
|
|
14
|
+
io-console (0.9.5)
|
|
15
|
+
json (3.2.0)
|
|
16
16
|
language_server-protocol (3.17.0.6)
|
|
17
17
|
lint_roller (1.1.0)
|
|
18
18
|
method_source (1.1.0)
|
|
19
19
|
mini_portile2 (2.8.9)
|
|
20
|
-
nokogiri (1.19.
|
|
20
|
+
nokogiri (1.19.7)
|
|
21
21
|
mini_portile2 (~> 2.8.2)
|
|
22
22
|
racc (~> 1.4)
|
|
23
|
-
parallel (2.
|
|
24
|
-
parser (3.3.
|
|
23
|
+
parallel (2.3.0)
|
|
24
|
+
parser (3.3.14.0)
|
|
25
25
|
ast (~> 2.4.1)
|
|
26
26
|
racc
|
|
27
|
-
prism (1.
|
|
28
|
-
pry (0.16.
|
|
27
|
+
prism (2.1.0)
|
|
28
|
+
pry (0.16.1)
|
|
29
29
|
coderay (~> 1.1)
|
|
30
30
|
method_source (~> 1.0)
|
|
31
31
|
reline (>= 0.6.0)
|
|
32
32
|
racc (1.8.1)
|
|
33
33
|
rainbow (3.1.1)
|
|
34
34
|
rake (13.4.2)
|
|
35
|
-
regexp_parser (2.
|
|
35
|
+
regexp_parser (2.13.4)
|
|
36
36
|
reline (0.7.0)
|
|
37
37
|
io-console (~> 0.5)
|
|
38
38
|
rspec (3.13.2)
|
|
39
39
|
rspec-core (~> 3.13.0)
|
|
40
40
|
rspec-expectations (~> 3.13.0)
|
|
41
41
|
rspec-mocks (~> 3.13.0)
|
|
42
|
-
rspec-core (3.13.
|
|
42
|
+
rspec-core (3.13.7)
|
|
43
43
|
rspec-support (~> 3.13.0)
|
|
44
|
-
rspec-expectations (3.13.
|
|
44
|
+
rspec-expectations (3.13.6)
|
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
46
46
|
rspec-support (~> 3.13.0)
|
|
47
|
-
rspec-mocks (3.13.
|
|
47
|
+
rspec-mocks (3.13.9)
|
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
49
49
|
rspec-support (~> 3.13.0)
|
|
50
|
-
rspec-support (3.13.
|
|
51
|
-
rubocop (1.
|
|
52
|
-
json (
|
|
50
|
+
rspec-support (3.13.8)
|
|
51
|
+
rubocop (1.93.0)
|
|
52
|
+
json (>= 2.3)
|
|
53
53
|
language_server-protocol (~> 3.17.0.2)
|
|
54
54
|
lint_roller (~> 1.1.0)
|
|
55
55
|
parallel (>= 1.10)
|
|
56
56
|
parser (>= 3.3.0.2)
|
|
57
57
|
rainbow (>= 2.2.2, < 4.0)
|
|
58
|
-
regexp_parser (>= 2.
|
|
59
|
-
rubocop-ast (>= 1.
|
|
58
|
+
regexp_parser (>= 2.11.3, < 3.0)
|
|
59
|
+
rubocop-ast (>= 1.54.0, < 2.0)
|
|
60
60
|
ruby-progressbar (~> 1.7)
|
|
61
61
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
62
|
-
rubocop-ast (1.
|
|
62
|
+
rubocop-ast (1.54.0)
|
|
63
|
+
ast (~> 2.4)
|
|
63
64
|
parser (>= 3.3.7.2)
|
|
64
|
-
prism (
|
|
65
|
+
prism (>= 1.7)
|
|
66
|
+
racc
|
|
65
67
|
ruby-progressbar (1.13.0)
|
|
66
|
-
simplecov (1.
|
|
67
|
-
unicode-display_width (3.
|
|
68
|
-
unicode-emoji (~> 4.
|
|
69
|
-
unicode-emoji (4.
|
|
68
|
+
simplecov (1.3.2)
|
|
69
|
+
unicode-display_width (3.3.0)
|
|
70
|
+
unicode-emoji (~> 4.3)
|
|
71
|
+
unicode-emoji (4.3.0)
|
|
70
72
|
warning (1.6.0)
|
|
71
|
-
yard (0.9.
|
|
72
|
-
yard-lint (1.
|
|
73
|
+
yard (0.9.46)
|
|
74
|
+
yard-lint (1.15.0)
|
|
73
75
|
yard (~> 0.9)
|
|
74
76
|
zeitwerk (~> 2.6)
|
|
75
77
|
zeitwerk (2.8.3)
|
data/README.md
CHANGED
|
@@ -125,7 +125,7 @@ llm-docs-builder generate --config llm-docs-builder.yml
|
|
|
125
125
|
```yaml
|
|
126
126
|
# llm-docs-builder.yml
|
|
127
127
|
docs: ./docs
|
|
128
|
-
base_url: https://myproject.io
|
|
128
|
+
base_url: https://myproject.io # Base URL for expanding relative links
|
|
129
129
|
title: My Project
|
|
130
130
|
description: Brief description
|
|
131
131
|
body: Optional body content between description and sections
|
|
@@ -163,8 +163,22 @@ calculate_compression: false # Calculate compression ratios (slower)
|
|
|
163
163
|
excludes:
|
|
164
164
|
- "**/private/**"
|
|
165
165
|
- "**/drafts/**"
|
|
166
|
+
include_hidden: false # Include files in hidden directories (e.g. .github/)
|
|
166
167
|
```
|
|
167
168
|
|
|
169
|
+
**Output file (`output`):** the `llms.txt` path that `generate` writes. `transform` does not use it: it prints to stdout, or writes the file given with `-o`.
|
|
170
|
+
|
|
171
|
+
**File selection (`generate` and `bulk-transform`):** both commands pick the same `.md` files under `docs`.
|
|
172
|
+
- `excludes` patterns match the path relative to `docs` (`private/a.md`) or the path starting with the `docs` value as written (`./docs/private/a.md`); a trailing `/**` matches files at any depth.
|
|
173
|
+
- Hidden directories (names starting with `.`, e.g. `.github/`) are skipped by default. Set `include_hidden: true` to include their files. Hidden files (e.g. `.notes.md`) are always skipped.
|
|
174
|
+
|
|
175
|
+
**Link expansion (`base_url`):** relative links become absolute URLs.
|
|
176
|
+
- Inline links, images (also linked images, `[](../intro.md)`) and reference-style definitions (`[a]: ../intro.md`) are expanded. `<path with spaces>` destinations are resolved and their spaces encoded as `%20`.
|
|
177
|
+
- Relative links resolve from `base_url` (`relative_links: base_url`, the default): with `base_url: https://myproject.io/docs`, `../intro.md` becomes `https://myproject.io/intro.md`, and `[Setup](Kafka-Setup)` in `Getting-Started/index.md` becomes `https://myproject.io/docs/Kafka-Setup`. This fits sites that keep each page in its own directory (`<Page>/index.md`) with links written relative to the docs root.
|
|
178
|
+
- `relative_links: file` makes `bulk-transform` resolve links from each file's directory under `docs` instead, like a browser on a file tree: `./setup.md` in `guides/intro.md` becomes `<base_url>/guides/setup.md`, and a query-only link (`[q](?tab=2)`) resolves to the current page (`.../page.md?tab=2`). Single-file `transform` always resolves from `base_url`.
|
|
179
|
+
- Links starting with `/` resolve from `base_url`.
|
|
180
|
+
- Left unchanged: links in fenced code, indented code and inline code; anchors (`#x`); protocol-relative URLs (`//cdn.io/a.md`); URLs with any scheme, in any case (`HTTPS:`, `sftp:`, `urn:`, `mailto:`); HTML `<a href>` and `<img src>`.
|
|
181
|
+
|
|
168
182
|
## CLI Commands
|
|
169
183
|
|
|
170
184
|
```bash
|
|
@@ -183,31 +197,34 @@ llm-docs-builder version # Show version
|
|
|
183
197
|
-d, --docs PATH Documentation path
|
|
184
198
|
-o, --output PATH Output file
|
|
185
199
|
-u, --url URL URL for comparison
|
|
200
|
+
-f, --file PATH Local markdown file for comparison
|
|
186
201
|
-v, --verbose Detailed output
|
|
187
202
|
```
|
|
188
203
|
|
|
189
204
|
## Serving Optimized Docs to AI Bots
|
|
190
205
|
|
|
191
|
-
After using `bulk-transform` with `suffix: .llm`, configure your web server to serve optimized versions to AI bots:
|
|
206
|
+
After using `bulk-transform` with `suffix: .llm`, configure your web server to serve optimized versions to AI bots. Pages without an `.llm.md` version are served as is:
|
|
192
207
|
|
|
193
208
|
**Apache (.htaccess):**
|
|
194
209
|
```apache
|
|
195
210
|
SetEnvIf User-Agent "(?i)(openai|anthropic|claude|gpt)" IS_LLM_BOT
|
|
211
|
+
RewriteEngine On
|
|
196
212
|
RewriteCond %{ENV:IS_LLM_BOT} !^$
|
|
213
|
+
RewriteCond %{REQUEST_URI} !\.llm\.md$
|
|
214
|
+
RewriteCond %{REQUEST_FILENAME} ^(.+)\.md$
|
|
215
|
+
RewriteCond %1.llm.md -f
|
|
197
216
|
RewriteRule ^(.*)\.md$ $1.llm.md [L]
|
|
198
217
|
```
|
|
199
218
|
|
|
200
219
|
**Nginx:**
|
|
201
220
|
```nginx
|
|
202
|
-
map $http_user_agent $
|
|
203
|
-
default
|
|
204
|
-
"~*(
|
|
221
|
+
map $http_user_agent $llm_suffix {
|
|
222
|
+
default "";
|
|
223
|
+
"~*(openai|anthropic|claude|gpt)" ".llm";
|
|
205
224
|
}
|
|
206
225
|
|
|
207
|
-
location ~ ^/docs/(
|
|
208
|
-
|
|
209
|
-
rewrite ^(.*)\.md$ $1.llm.md last;
|
|
210
|
-
}
|
|
226
|
+
location ~ ^/docs/(?<doc>.*)\.md$ {
|
|
227
|
+
try_files /docs/$doc$llm_suffix.md $uri =404;
|
|
211
228
|
}
|
|
212
229
|
```
|
|
213
230
|
|
|
@@ -258,7 +275,10 @@ api = API.new
|
|
|
258
275
|
```markdown
|
|
259
276
|
# API Documentation
|
|
260
277
|
|
|
261
|
-
|
|
278
|
+
|
|
279
|
+
> Important: This is a note
|
|
280
|
+
|
|
281
|
+
[Click here to see the complete API documentation](./api.md)
|
|
262
282
|
|
|
263
283
|
api = API.new
|
|
264
284
|
```
|
|
@@ -310,8 +330,8 @@ Generate enriched llms.txt files with token counts, timestamps, and priority lab
|
|
|
310
330
|
**Enhanced llms.txt (with metadata enabled):**
|
|
311
331
|
```markdown
|
|
312
332
|
- [Getting Started](https://myproject.io/docs/Getting-Started.md): Quick start guide (tokens:450, updated:2025-10-13, priority:high)
|
|
313
|
-
- [Configuration](https://myproject.io/docs/Configuration.md): Configuration options (tokens:2800, updated:2025-10-12, priority:
|
|
314
|
-
- [Advanced Topics](https://myproject.io/docs/Advanced.md): Deep dive topics (tokens:5200, updated:2025-09-15, priority:
|
|
333
|
+
- [Configuration](https://myproject.io/docs/Configuration.md): Configuration options (tokens:2800, updated:2025-10-12, priority:medium)
|
|
334
|
+
- [Advanced Topics](https://myproject.io/docs/Advanced.md): Deep dive topics (tokens:5200, updated:2025-09-15, priority:low)
|
|
315
335
|
```
|
|
316
336
|
|
|
317
337
|
**Benefits:**
|
|
@@ -336,7 +356,7 @@ calculate_compression: true # Show compression ratios (slower, requires transfor
|
|
|
336
356
|
Documents are automatically organized into multiple sections based on priority, following the llms.txt specification:
|
|
337
357
|
|
|
338
358
|
**Priority-based categorization:**
|
|
339
|
-
- **Documentation** (priority 1-3):
|
|
359
|
+
- **Documentation** (priority 1-3): README, getting started guides, user guides, API docs and every page that matches no other rule
|
|
340
360
|
- **Examples** (priority 4-5): Tutorials and example files
|
|
341
361
|
- **Optional** (priority 6-7): Advanced topics and reference documentation
|
|
342
362
|
|
|
@@ -350,6 +370,8 @@ Documents are automatically organized into multiple sections based on priority,
|
|
|
350
370
|
|
|
351
371
|
- [README](README.md): Main documentation
|
|
352
372
|
- [Getting Started](getting-started.md): Quick start guide
|
|
373
|
+
- [Configuration](configuration.md): Configuration options
|
|
374
|
+
- [API](api.md): Public API
|
|
353
375
|
|
|
354
376
|
## Examples
|
|
355
377
|
|
|
@@ -358,8 +380,8 @@ Documents are automatically organized into multiple sections based on priority,
|
|
|
358
380
|
|
|
359
381
|
## Optional
|
|
360
382
|
|
|
361
|
-
- [Advanced Topics](advanced.md): Deep dive into advanced features
|
|
362
383
|
- [API Reference](reference.md): Complete API reference
|
|
384
|
+
- [Advanced Topics](advanced.md): Deep dive into advanced features
|
|
363
385
|
```
|
|
364
386
|
|
|
365
387
|
Empty sections are automatically omitted. The "Optional" section aligns with the llms.txt spec for marking secondary content that can be skipped when context windows are limited.
|
|
@@ -403,15 +425,17 @@ All compression features can be used individually for fine-grained control:
|
|
|
403
425
|
- `remove_images: true` - Remove all image syntax
|
|
404
426
|
- `remove_code_examples: true` - Remove fenced code blocks, indented code, and inline code
|
|
405
427
|
- `remove_blockquotes: true` - Remove blockquote formatting (preserves content)
|
|
406
|
-
- `remove_duplicates: true` - Remove
|
|
407
|
-
- `remove_stopwords: true` - Remove common stopwords from prose (preserves code blocks)
|
|
428
|
+
- `remove_duplicates: true` - Remove paragraphs that repeat an earlier one after whitespace and case normalization (paragraphs with code are kept)
|
|
429
|
+
- `remove_stopwords: true` - Remove common stopwords from prose (preserves code blocks, inline code and bare URLs)
|
|
430
|
+
|
|
431
|
+
`remove_comments`, `remove_badges`, `remove_images` and `remove_blockquotes` leave code (fenced, indented and inline) unchanged.
|
|
408
432
|
|
|
409
433
|
### Content Enhancement Options
|
|
410
434
|
|
|
411
435
|
- `generate_toc: true` - Generate table of contents from headings with anchor links
|
|
412
436
|
- `custom_instruction: "text"` - Inject AI context message at document top
|
|
413
437
|
- `simplify_links: true` - Simplify verbose link text (e.g., "Click here to see the docs" → "docs")
|
|
414
|
-
- `convert_urls: true` - Convert `.html`/`.htm` URLs to `.md` format
|
|
438
|
+
- `convert_urls: true` - Convert `.html`/`.htm` URLs to `.md` format, keeping anchors and queries (`../intro.html#x` → `../intro.md#x`): absolute `http(s)` URLs anywhere in the text, and relative link and reference-style definition targets. URLs in code are unchanged
|
|
415
439
|
- `normalize_whitespace: true` - Reduce excessive blank lines and remove trailing whitespace
|
|
416
440
|
|
|
417
441
|
## License
|
|
@@ -29,8 +29,11 @@ module LlmDocsBuilder
|
|
|
29
29
|
# @param options [Hash] transformation options
|
|
30
30
|
# @option options [String] :base_url base URL for expanding relative links
|
|
31
31
|
# @option options [Boolean] :convert_urls convert HTML URLs to markdown format
|
|
32
|
+
# @option options [String] :relative_links `'base_url'` (default) resolves relative links from
|
|
33
|
+
# `base_url`, `'file'` from each file's directory
|
|
32
34
|
# @option options [String] :suffix suffix for transformed files (default: '.llm')
|
|
33
35
|
# @option options [Array<String>] :excludes glob patterns for files to exclude
|
|
36
|
+
# @option options [Boolean] :include_hidden include files in hidden directories
|
|
34
37
|
# @option options [Boolean] :verbose enable verbose output
|
|
35
38
|
def initialize(docs_path, options = {})
|
|
36
39
|
@docs_path = docs_path
|
|
@@ -53,8 +56,6 @@ module LlmDocsBuilder
|
|
|
53
56
|
transformed_files = []
|
|
54
57
|
|
|
55
58
|
markdown_files.each do |file_path|
|
|
56
|
-
next if should_exclude?(file_path)
|
|
57
|
-
|
|
58
59
|
puts "Transforming #{file_path}..." if options[:verbose]
|
|
59
60
|
|
|
60
61
|
transformed_content = transform_file(file_path)
|
|
@@ -76,45 +77,29 @@ module LlmDocsBuilder
|
|
|
76
77
|
|
|
77
78
|
# Recursively scans the docs directory for markdown files
|
|
78
79
|
#
|
|
79
|
-
#
|
|
80
|
+
# See MarkdownFinder for the files it skips
|
|
80
81
|
#
|
|
81
|
-
# @return [Array<String>] paths to markdown files
|
|
82
|
+
# @return [Array<String>] sorted paths to markdown files
|
|
82
83
|
def find_markdown_files
|
|
83
|
-
files
|
|
84
|
-
|
|
85
|
-
Find.find(docs_path) do |path|
|
|
86
|
-
next unless File.file?(path)
|
|
87
|
-
next unless path.match?(/\.md$/i)
|
|
88
|
-
next if File.basename(path).start_with?('.')
|
|
89
|
-
|
|
90
|
-
files << path
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
files.sort
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Tests if file matches any exclusion pattern from options
|
|
97
|
-
#
|
|
98
|
-
# Uses File.fnmatch with pathname and dotmatch flags
|
|
99
|
-
#
|
|
100
|
-
# @param file_path [String] path to check
|
|
101
|
-
# @return [Boolean] true if file should be excluded
|
|
102
|
-
def should_exclude?(file_path)
|
|
103
|
-
excludes = Array(options[:excludes])
|
|
104
|
-
|
|
105
|
-
excludes.any? do |pattern|
|
|
106
|
-
File.fnmatch(pattern, file_path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
|
|
107
|
-
end
|
|
84
|
+
MarkdownFinder.new(docs_path, options).files.sort
|
|
108
85
|
end
|
|
109
86
|
|
|
110
87
|
# Applies markdown transformations to a single file
|
|
111
88
|
#
|
|
112
|
-
# Creates MarkdownTransformer instance and delegates transformation
|
|
89
|
+
# Creates MarkdownTransformer instance and delegates transformation. With `relative_links: 'file'`
|
|
90
|
+
# it passes the file's path relative to the docs directory so relative links resolve from its own
|
|
91
|
+
# location; otherwise they resolve from `base_url`.
|
|
113
92
|
#
|
|
114
93
|
# @param file_path [String] path to markdown file
|
|
115
94
|
# @return [String] transformed content
|
|
116
95
|
def transform_file(file_path)
|
|
117
|
-
|
|
96
|
+
file_options = options
|
|
97
|
+
if options[:relative_links].to_s == 'file'
|
|
98
|
+
source_path = Pathname.new(file_path).relative_path_from(Pathname.new(docs_path)).to_s
|
|
99
|
+
file_options = options.merge(source_path: source_path)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
transformer = MarkdownTransformer.new(file_path, file_options)
|
|
118
103
|
transformer.transform
|
|
119
104
|
end
|
|
120
105
|
|