solidworks_mcp.doc_links.llms_txt¶
solidworks_mcp.doc_links.llms_txt ¶
Build docs/llms.txt from the docs, and check a committed copy.
The file follows the llms.txt format: a # title, a > summary,
then ## sections of - [title](url): summary entries. Every title
and summary is copied word for word from the page it links to (see
:func:.pages.opening), and the same content rules hold for the builder
and the checker, so a hand edit can't match a bad build.
Attributes¶
_ENTRY
module-attribute
¶
_SHAPES
module-attribute
¶
_SHAPES = (re.compile('^# \\S.*$'), re.compile('^> \\S.*$'), re.compile('^## \\S.*$'), _ENTRY, re.compile('^$'))
Classes¶
DocsError ¶
Bases: Exception
A page can't give what llms.txt needs from it (names the page).
Entry
dataclass
¶
One page's line in llms.txt.
Attributes:
| Name | Type | Description |
|---|---|---|
section |
str
|
Its |
page |
str
|
The page's path under |
title |
str
|
The page's title. |
url |
str
|
The page's published URL. |
summary |
str
|
The page's opening paragraph. |
Site
dataclass
¶
The settings llms.txt and the link checks use.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
description |
str
|
|
url |
str
|
|
repo_url |
str
|
|
nav |
list[Any]
|
The nav as written in |
Functions:¶
_entry_differences ¶
Entries whose title or summary differs from the page, or are missing/extra.
Source code in src/solidworks_mcp/doc_links/llms_txt.py
_first_difference ¶
The first line where the committed file and a fresh build differ.
Source code in src/solidworks_mcp/doc_links/llms_txt.py
_ours ¶
Whether url is the docs site or this repository.
build ¶
The text of llms.txt for the docs under root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The repository root. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The file's text, ending in a newline. |
Raises:
| Type | Description |
|---|---|
DocsError
|
As :func: |
Source code in src/solidworks_mcp/doc_links/llms_txt.py
check ¶
Problems with the committed llms.txt; empty when it is right.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The repository root. |
required |
committed
|
str | None
|
The file's text; read from |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
One message per problem: a content rule broken (with its line |
list[str]
|
number), an entry whose title or summary differs from its page |
list[str]
|
(with the expected and the found text), a page missing or extra, |
list[str]
|
or else the first line that differs. Each ends by naming the |
list[str]
|
rebuild command when the fix is a rebuild. |
Source code in src/solidworks_mcp/doc_links/llms_txt.py
entries ¶
Every nav page's entry, in nav order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The repository root. |
required |
site
|
Site | None
|
The site settings, read from |
None
|
Returns:
| Type | Description |
|---|---|
list[Entry]
|
The entries. |
Raises:
| Type | Description |
|---|---|
DocsError
|
When a page has no title or opening paragraph, or its title or opening breaks a content rule. |
Source code in src/solidworks_mcp/doc_links/llms_txt.py
line_problems ¶
What is wrong with one line of llms.txt, if anything.
The rules (spec docs/llms-txt): one of the allowed shapes; every URL
under site_url or repo_url; no control or format characters
(zero-width, byte-order mark, bidirectional controls); no HTML tag or
comment outside code spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
The line, without its line break. |
required |
site
|
Site
|
The site settings (for the allowed URLs). |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A message per problem; empty when the line is fine. |
Source code in src/solidworks_mcp/doc_links/llms_txt.py
load_site ¶
Read mkdocs.yml under root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The repository root. |
required |
Returns:
| Type | Description |
|---|---|
Site
|
The site settings and nav. |
Source code in src/solidworks_mcp/doc_links/pages.py
nav_pages ¶
The nav's Markdown pages, in nav order.
Entries that are not .md files in docs_dir (the generated API
reference, for one) are left out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nav
|
list[Any]
|
The nav from |
required |
docs_dir
|
Path
|
The |
required |
Returns:
| Type | Description |
|---|---|
list[NavPage]
|
One entry per page; top-level pages first, under |
Source code in src/solidworks_mcp/doc_links/pages.py
opening ¶
The page's # title and its first prose paragraph.
Prose is a paragraph before the first lower heading that is not a blockquote, admonition, list, table, image, badge line, HTML, rule or code (fenced or indented).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The page's Markdown. |
required |
page
|
str
|
The page's path, for the error message. |
required |
Returns:
| Type | Description |
|---|---|
Opening
|
The title and summary. |
Raises:
| Type | Description |
|---|---|
DocsError
|
When the page has no |
Source code in src/solidworks_mcp/doc_links/pages.py
page_url ¶
The published URL of the page at path (directory URLs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_url
|
str
|
|
required |
path
|
str
|
The page's path relative to |
required |
Returns:
| Type | Description |
|---|---|
str
|
|
str
|
|