Skip to content

Commit b2cb85d

Browse files
committed
💚 Move execution of split_readme script to sphinx config and rename github action files
1 parent be76202 commit b2cb85d

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

‎.github/workflows/cdci.yml‎ renamed to ‎.github/workflows/cicd.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python package
1+
name: CICD Python Package
22

33
on:
44
push:

‎.github/workflows/docs.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test documentation building, and publish report to GitHub Pages
1+
name: Docs
22

33
on:
44
push:
@@ -27,9 +27,6 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install -e .[docs]
30-
- name: Split README into sections
31-
run: |
32-
python docs/split_readme.py
3330
- name: Build references
3431
run: |
3532
cd docs

‎docs/conf.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@
137137
PROJECT_ROOT = Path(__file__).parent.parent
138138
PACKAGE_ROOT = PROJECT_ROOT / "src" / "vuegen"
139139

140+
def run_split_readme(_):
141+
print("[conf.py] Splitting README.md into sections...")
142+
from split_readme import process_readme
143+
144+
readme_path = PROJECT_ROOT / "README.md"
145+
output_dir = PROJECT_ROOT / "docs" / "sections_readme"
146+
process_readme(readme_path, output_dir)
147+
140148
def run_apidoc(_):
149+
print("[conf.py] Running sphinx-apidoc...")
141150
from sphinx.ext import apidoc
142151

143152
apidoc.main(
@@ -155,4 +164,5 @@ def run_apidoc(_):
155164
)
156165

157166
def setup(app):
167+
app.connect("builder-inited", run_split_readme)
158168
app.connect("builder-inited", run_apidoc)

‎docs/split_readme.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@ def convert_gfm_to_sphinx(content, links):
5252
return content
5353

5454

55-
def process_readme():
56-
readme_path = Path(__file__).resolve().parent.parent / "README.md"
57-
readme = readme_path.read_text()
55+
def process_readme(readme_path, output_dir):
56+
readme = Path(readme_path).read_text()
5857

5958
# Extract links from README
6059
links = extract_links_from_readme(readme)
6160

62-
# Create docs/sections directory
63-
output_dir = Path("./sections_readme")
64-
output_dir.mkdir(exist_ok=True)
61+
# Create output directory
62+
output_dir.mkdir(exist_ok=True, parents=True)
6563

6664
for section_title, filename in SECTION_MAPPING.items():
6765
content = extract_section(readme, section_title)
@@ -76,4 +74,6 @@ def process_readme():
7674

7775

7876
if __name__ == "__main__":
79-
process_readme()
77+
default_readme = Path(__file__).resolve().parent.parent / "README.md"
78+
output_sections_readme = Path("./sections_readme")
79+
process_readme(default_readme, output_sections_readme)

0 commit comments

Comments
 (0)