solidworks_mcp.doc_links.pages¶
solidworks_mcp.doc_links.pages ¶
Read the docs: the mkdocs nav, and each page's title, opening and anchors.
Everything here reads Markdown source; nothing renders it. The rules for
what counts as a page's opening paragraph are in the docs/llms-txt
spec, and heading ids follow Python-Markdown's toc extension, which
the docs site uses.
Attributes¶
_NOT_PROSE
module-attribute
¶
_NOT_PROSE = re.compile('^\\s*(>|!!!|\\?\\?\\?|===|[-*+]\\s|\\d+[.)]\\s|\\||<|!\\[|\\[!\\[|---|\\*\\*\\*|___|:::)')
Classes¶
DocsError ¶
Bases: Exception
A page can't give what llms.txt needs from it (names the page).
NavPage
dataclass
¶
A Markdown page listed in the nav.
Attributes:
| Name | Type | Description |
|---|---|---|
section |
str
|
The top-level nav section it is under ( |
path |
str
|
Its path relative to |
Opening
dataclass
¶
A page's title and opening paragraph.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
The |
summary |
str
|
The first prose paragraph, links reduced to their text, lines joined with single spaces. |
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:¶
_entries ¶
The (title, value) pairs of one nav item (a bare path has no title).
_inline_text ¶
Reduce links and images to their text, leaving code spans as written.
Code spans are set aside first, so link syntax inside one is kept, and
a link whose text is a code span ([`x.py`](x.py)) becomes the span.
Source code in src/solidworks_mcp/doc_links/pages.py
_is_page ¶
_is_prose ¶
Whether a paragraph's lines (first line unstripped) are prose.
Source code in src/solidworks_mcp/doc_links/pages.py
_paths ¶
Every page path in a nav section, nested sections included, in order.
Source code in src/solidworks_mcp/doc_links/pages.py
_split_attrs ¶
Split a heading's trailing {#id .class} off; return (text, id).
Source code in src/solidworks_mcp/doc_links/pages.py
_strip_links ¶
Links and images in plain (non-code) text, reduced to their text.
Source code in src/solidworks_mcp/doc_links/pages.py
_unique ¶
slug, or slug_1, slug_2, ... when it is already taken.
heading_ids ¶
Every anchor the page's headings get, and every {#id} it sets.
Repeated slugs get _1, _2 in page order, as the toc
extension makes them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The page's Markdown. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
The ids. |
Source code in src/solidworks_mcp/doc_links/pages.py
heading_text ¶
A heading's text as the toc extension sees it, before slugifying.
Links become their text, code spans their content, and emphasis markers and HTML tags go.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
str
|
The heading as written, attributes removed. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Its plain text. |
Source code in src/solidworks_mcp/doc_links/pages.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
|
|
Source code in src/solidworks_mcp/doc_links/pages.py
slugify ¶
Python-Markdown's default toc slugify, without needing markdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The heading's text. |
required |
separator
|
str
|
What spaces and hyphens become. |
'-'
|
Returns:
| Type | Description |
|---|---|
str
|
The heading's id. |
Source code in src/solidworks_mcp/doc_links/pages.py
source_lines ¶
The page's lines as (line number, text, inside a fenced code block).
Front matter, if any, is blanked out (its lines kept so line numbers still match the file). Fence lines themselves count as code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The page's Markdown. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[int, str, bool]]
|
One tuple per line, numbered from 1. |