fr-docs 5.1.0__tar.gz → 5.3.0__tar.gz
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.
- {fr_docs-5.1.0 → fr_docs-5.3.0}/PKG-INFO +1 -1
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/build.py +5 -5
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/markdown.py +70 -15
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs.egg-info/PKG-INFO +1 -1
- {fr_docs-5.1.0 → fr_docs-5.3.0}/pyproject.toml +1 -1
- {fr_docs-5.1.0 → fr_docs-5.3.0}/LICENSE.md +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/README.md +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/__init__.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/__main__.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/config.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/config_accessors.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/frontmatter.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/git.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/html_pipeline.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/init.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/search.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/slug.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/syntax.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/template.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/update.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs/utils.py +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs.egg-info/SOURCES.txt +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs.egg-info/dependency_links.txt +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs.egg-info/entry_points.txt +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs.egg-info/requires.txt +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/fr_docs.egg-info/top_level.txt +0 -0
- {fr_docs-5.1.0 → fr_docs-5.3.0}/setup.cfg +0 -0
|
@@ -62,9 +62,9 @@ def _best_zstd_level(raw: bytes, configured: int) -> int:
|
|
|
62
62
|
if len(raw) < 1024:
|
|
63
63
|
return min(configured, 19)
|
|
64
64
|
|
|
65
|
-
best_level, best_size = 1, len(zstandard.ZstdCompressor(level=1).compress(raw))
|
|
65
|
+
best_level, best_size = 1, len(zstandard.ZstdCompressor(level=1, threads=16).compress(raw))
|
|
66
66
|
for level in range(2, configured + 1):
|
|
67
|
-
size = len(zstandard.ZstdCompressor(level=level).compress(raw))
|
|
67
|
+
size = len(zstandard.ZstdCompressor(level=level, threads=16).compress(raw))
|
|
68
68
|
if size < best_size:
|
|
69
69
|
best_level, best_size = level, size
|
|
70
70
|
return best_level
|
|
@@ -307,7 +307,7 @@ def _write_zstd_json(config, filename, value):
|
|
|
307
307
|
return len(raw), src.stat().st_size
|
|
308
308
|
|
|
309
309
|
compressed = zstandard.ZstdCompressor(
|
|
310
|
-
level=_best_zstd_level(raw, zstd_level(config))
|
|
310
|
+
level=_best_zstd_level(raw, zstd_level(config)), threads=16
|
|
311
311
|
).compress(raw)
|
|
312
312
|
path = Path(config["_out_dir"]) / filename
|
|
313
313
|
path.write_bytes(compressed)
|
|
@@ -674,7 +674,7 @@ def main(argv=None) -> None:
|
|
|
674
674
|
# Compress search index
|
|
675
675
|
search_raw = json.dumps(search_index, separators=(",", ":")).encode("utf-8")
|
|
676
676
|
compressed = zstandard.ZstdCompressor(
|
|
677
|
-
level=_best_zstd_level(search_raw, zstd_level(config))
|
|
677
|
+
level=_best_zstd_level(search_raw, zstd_level(config)), threads=16
|
|
678
678
|
).compress(search_raw)
|
|
679
679
|
search_index_path = Path(config["_out_dir"], search_index_filename(config))
|
|
680
680
|
search_index_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -732,7 +732,7 @@ def main(argv=None) -> None:
|
|
|
732
732
|
"utf-8"
|
|
733
733
|
)
|
|
734
734
|
compressed = zstandard.ZstdCompressor(
|
|
735
|
-
level=_best_zstd_level(raw, zstd_level(config))
|
|
735
|
+
level=_best_zstd_level(raw, zstd_level(config)), threads=16
|
|
736
736
|
).compress(raw)
|
|
737
737
|
highlight_cache_file.parent.mkdir(parents=True, exist_ok=True)
|
|
738
738
|
highlight_cache_file.write_bytes(compressed)
|
|
@@ -108,14 +108,28 @@ def _extract_footnote_definitions(md_text):
|
|
|
108
108
|
return definitions
|
|
109
109
|
|
|
110
110
|
|
|
111
|
+
def _add_footnote_commas(html_text):
|
|
112
|
+
"""Add commas between consecutive footnote reference links.
|
|
113
|
+
|
|
114
|
+
``[^tag1][^tag2]`` renders as ``<a>2</a><a>3</a>`` which reads as "23";
|
|
115
|
+
insert a comma so it reads "2,3".
|
|
116
|
+
"""
|
|
117
|
+
return re.sub(
|
|
118
|
+
r'(<sup>\d+</sup></a>)(<a href="#fnref-[^"]+" class="footnote-ref">)',
|
|
119
|
+
r'\1,\2',
|
|
120
|
+
html_text,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
111
124
|
def process_footnotes(md_text):
|
|
112
125
|
"""Process footnote definitions and references.
|
|
113
126
|
|
|
114
127
|
Converts ``[^tag]`` references into superscript links:
|
|
115
128
|
<a href="url" class="footnote-ref"><sup>n</sup></a>
|
|
116
129
|
|
|
117
|
-
Returns tuple of (processed_text,
|
|
118
|
-
of {tag, url, title, index} dicts
|
|
130
|
+
Returns tuple of (processed_text, references) where references is a list
|
|
131
|
+
of {tag, url, title, index} dicts for ALL definitions that have a title,
|
|
132
|
+
in first-use order (footnote references first, then unused definitions).
|
|
119
133
|
"""
|
|
120
134
|
definitions = _extract_footnote_definitions(md_text)
|
|
121
135
|
if not definitions:
|
|
@@ -123,6 +137,7 @@ def process_footnotes(md_text):
|
|
|
123
137
|
|
|
124
138
|
footnotes = []
|
|
125
139
|
footnote_counter = {}
|
|
140
|
+
footnote_order = {}
|
|
126
141
|
|
|
127
142
|
def _repl(m):
|
|
128
143
|
tag = m.group(1).strip()
|
|
@@ -131,7 +146,7 @@ def process_footnotes(md_text):
|
|
|
131
146
|
if tag not in footnote_counter:
|
|
132
147
|
footnote_counter[tag] = len(footnotes) + 1
|
|
133
148
|
idx = footnote_counter[tag]
|
|
134
|
-
|
|
149
|
+
footnote_order[tag] = idx
|
|
135
150
|
if not any(fn["tag"] == tag for fn in footnotes):
|
|
136
151
|
footnotes.append(
|
|
137
152
|
{
|
|
@@ -143,36 +158,76 @@ def process_footnotes(md_text):
|
|
|
143
158
|
)
|
|
144
159
|
return f'<a href="#fnref-{tag}" class="footnote-ref"><sup>{idx}</sup></a>'
|
|
145
160
|
|
|
146
|
-
#
|
|
161
|
+
# Replace footnote references [^tag] with HTML links
|
|
147
162
|
processed_text = FOOTNOTE_REF_RE.sub(_repl, md_text)
|
|
148
|
-
|
|
163
|
+
|
|
164
|
+
# Only remove definition lines for tags that are actually footnote tags
|
|
165
|
+
# (referenced with [^tag]). Keep standard markdown reference link
|
|
166
|
+
# definitions ([ref]: URL ...) intact so [text][ref] links resolve.
|
|
167
|
+
footnote_ref_tags = set(FOOTNOTE_REF_RE.findall(md_text))
|
|
168
|
+
|
|
169
|
+
def _remove_fn_def(m):
|
|
170
|
+
tag = m.group(1)
|
|
171
|
+
if tag in footnote_ref_tags:
|
|
172
|
+
return ""
|
|
173
|
+
return m.group(0)
|
|
174
|
+
|
|
149
175
|
processed_text = re.sub(
|
|
150
|
-
r"(?m)^\[([^\]]+)\]:\s*\S+.*(?:\n?)$",
|
|
176
|
+
r"(?m)^\[([^\]]+)\]:\s*\S+.*(?:\n?)$",
|
|
177
|
+
_remove_fn_def,
|
|
178
|
+
processed_text,
|
|
151
179
|
)
|
|
152
180
|
processed_text = re.sub(r"\n{3,}", "\n\n", processed_text)
|
|
153
181
|
|
|
154
|
-
|
|
182
|
+
# Add commas between consecutive footnote references
|
|
183
|
+
processed_text = _add_footnote_commas(processed_text)
|
|
184
|
+
|
|
185
|
+
# Build references list: all definitions with titles, in first-use order
|
|
186
|
+
references = []
|
|
187
|
+
used_indices = set()
|
|
188
|
+
|
|
189
|
+
# Add footnote-used tags that have titles, in first-use order
|
|
190
|
+
for tag, idx in sorted(footnote_order.items(), key=lambda kv: kv[1]):
|
|
191
|
+
if tag in definitions and definitions[tag]["title"]:
|
|
192
|
+
d = definitions[tag]
|
|
193
|
+
references.append(
|
|
194
|
+
{"tag": tag, "url": d["url"], "title": d["title"], "index": idx}
|
|
195
|
+
)
|
|
196
|
+
used_indices.add(tag)
|
|
197
|
+
|
|
198
|
+
# Add unused definitions that have titles (in definition order)
|
|
199
|
+
for tag, d in definitions.items():
|
|
200
|
+
if tag not in used_indices and d["title"]:
|
|
201
|
+
references.append(
|
|
202
|
+
{"tag": tag, "url": d["url"], "title": d["title"], "index": len(references) + 1}
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
return processed_text, references
|
|
155
206
|
|
|
156
207
|
|
|
157
|
-
def build_footnotes_html(
|
|
158
|
-
"""Build the
|
|
208
|
+
def build_footnotes_html(references):
|
|
209
|
+
"""Build the references HTML section for a page.
|
|
159
210
|
|
|
160
211
|
The section is appended before the footer content in the page body.
|
|
212
|
+
References includes all footnote definitions that have titles, renamed
|
|
213
|
+
from the previous "Footnotes" heading.
|
|
161
214
|
"""
|
|
162
|
-
if not
|
|
215
|
+
if not references:
|
|
163
216
|
return ""
|
|
164
217
|
items = []
|
|
165
|
-
for
|
|
166
|
-
title =
|
|
218
|
+
for ref in references:
|
|
219
|
+
title = ref.get("title") or ""
|
|
220
|
+
if not title:
|
|
221
|
+
continue
|
|
167
222
|
items.append(
|
|
168
|
-
f'<li id="fnref-{
|
|
169
|
-
f'<a href="{
|
|
223
|
+
f'<li id="fnref-{ref.get("tag")}" class="footnote-item">'
|
|
224
|
+
f'<a href="{ref.get("url")}" class="footnote-link" title="{html.escape(title)}">'
|
|
170
225
|
f"{html.escape(title)}</a></li>"
|
|
171
226
|
)
|
|
172
227
|
inner = "".join(items)
|
|
173
228
|
return (
|
|
174
229
|
'<div class="footnotes">'
|
|
175
|
-
'<h2 class="footnotes-heading">
|
|
230
|
+
'<h2 class="footnotes-heading">References</h2>'
|
|
176
231
|
f'<ol class="footnotes-list">{inner}</ol>'
|
|
177
232
|
"</div>"
|
|
178
233
|
)
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "fr-docs"
|
|
9
|
-
version = "5.
|
|
9
|
+
version = "5.3.0"
|
|
10
10
|
description = "Fast static documentation generator with search, versioning, and zero-config setup"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.14"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|