Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit 3a17941

Browse files
committed
init
1 parent 9655422 commit 3a17941

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

pcweb/markdown_api.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Write per-doc raw Markdown files under ``.web/public`` for ``<route>.md`` URLs."""
2+
3+
from pathlib import Path
4+
5+
from pcweb.pages.docs import doc_markdown_sources
6+
7+
PUBLIC_DIR = Path(".web/public")
8+
9+
10+
def generate_markdown_files() -> None:
11+
for route, source_path in doc_markdown_sources.items():
12+
resolved = Path(source_path)
13+
if not resolved.is_absolute():
14+
resolved = Path.cwd() / resolved
15+
if not resolved.is_file():
16+
continue
17+
18+
dest = PUBLIC_DIR / (route.strip("/") + ".md")
19+
dest.parent.mkdir(parents=True, exist_ok=True)
20+
dest.write_text(resolved.read_text(encoding="utf-8"), encoding="utf-8")

pcweb/pages/docs/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def get_components_from_metadata(current_doc):
132132
recipes_list = defaultdict(list)
133133
docs_ns = SimpleNamespace()
134134

135+
doc_markdown_sources: dict[str, str] = {}
136+
135137

136138
def exec_blocks(doc, href):
137139
"""Execute the exec and demo blocks in the document."""
@@ -281,6 +283,11 @@ def comp(_actual=actual_path):
281283
return make_docpage(resolved.route, resolved.display_title, virtual_doc, comp)
282284

283285

286+
for fd in flexdown_docs:
287+
doc_markdown_sources[doc_route_from_path(fd)] = doc_path_mapping.get(fd, fd)
288+
for virtual_doc, actual_path in docgen_docs.items():
289+
doc_markdown_sources[doc_route_from_path(virtual_doc)] = actual_path
290+
284291
doc_routes = [
285292
library,
286293
custom_components,

pcweb/pcweb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pcweb import styles
1010
from pcweb.constants import REFLEX_ASSETS_CDN
11+
from pcweb.markdown_api import generate_markdown_files
1112
from pcweb.meta.meta import favicons_links, to_cdn_image_url
1213
from pcweb.pages import page404, routes
1314
from pcweb.pages.docs import exec_blocks, outblocks
@@ -22,6 +23,8 @@
2223
for doc, href in outblocks:
2324
exec_blocks(doc, href)
2425

26+
generate_markdown_files()
27+
2528
# Create the app.
2629
app = rxe.App(
2730
style=styles.BASE_STYLE,

0 commit comments

Comments
 (0)