Skip to content

Commit 83153de

Browse files
added pages assets
1 parent 76527f0 commit 83153de

5 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Auto-generate docs index for KiCad-Simulation-Examples
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- "docs/**/index.md"
8+
- ".github/workflows/generate-and-deploy.yml"
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
build-index:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
with:
21+
persist-credentials: true
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.x"
27+
28+
- name: Generate all docs/index.md
29+
run: python scripts/generate_docs_index.py
30+
31+
- name: Commit & push changes
32+
run: |
33+
git config user.name "bot"
34+
git config user.email "bot@users.noreply.github.com"
35+
git add docs
36+
if ! git diff --cached --quiet; then
37+
git commit -m "🔁 Auto-generate docs index"
38+
git push origin HEAD:main
39+
else
40+
echo "✅ Indexes up to date"
41+
fi

docs/.indexignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO.md

docs/TODO.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# TODO
2+
3+
- Go over all examples
4+
- Export images and data for ipynb notebooks

docs/_config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
title: KiCad-Simulation-Examples
2+
description: >
3+
A FEASTorg project page for KiCad Simulation Examples.
4+
baseurl: "/KiCad-Simulation-Examples"
5+
url: "https://feastorg.github.io"
6+
7+
theme: minima
8+
plugins:
9+
- jekyll-feed
10+
- jekyll-seo-tag
11+
12+
markdown: kramdown
13+
kramdown:
14+
input: GFM
15+
16+
# Don't publish these
17+
exclude:
18+
- TODO.md
19+
- .indexignore
20+
21+
# automatically apply layout: page to all docs/*.md
22+
defaults:
23+
- scope:
24+
path: "" # everything under docs/
25+
type: "pages"
26+
values:
27+
layout: "page"

scripts/generate_docs_index.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
from pathlib import Path
3+
import fnmatch
4+
5+
6+
def load_ignore(dir_path: Path):
7+
ignore_file = dir_path / ".indexignore"
8+
patterns = []
9+
if ignore_file.exists():
10+
for line in ignore_file.read_text().splitlines():
11+
line = line.strip()
12+
if not line or line.startswith("#"):
13+
continue
14+
patterns.append(line)
15+
patterns.append("index.md") # always ignore old indexes
16+
return patterns
17+
18+
19+
def should_ignore(path: Path, patterns):
20+
return any(fnmatch.fnmatch(path.name, pat) for pat in patterns)
21+
22+
23+
def make_index(dir_path: Path):
24+
patterns = load_ignore(dir_path)
25+
readme = dir_path / "README.md"
26+
index = dir_path / "index.md"
27+
parts = []
28+
29+
# 1) README or fallback title
30+
if readme.exists() and not should_ignore(readme, patterns):
31+
parts.append(readme.read_text(encoding="utf-8"))
32+
parts.append("\n")
33+
else:
34+
title = dir_path.name.replace("_", " ").title() or "Documentation"
35+
parts.append(f"# {title}\n\n")
36+
37+
parts.append("## Contents\n\n")
38+
39+
# 2) List markdown files
40+
for md in sorted(dir_path.glob("*.md")):
41+
if should_ignore(md, patterns) or md.name.lower() in ("readme.md", "index.md"):
42+
continue
43+
title = md.stem.replace("_", " ").title()
44+
parts.append(f"- [{title}]({md.name})\n")
45+
parts.append("\n")
46+
47+
# 3) Recurse into subdirectories
48+
for sub in sorted([d for d in dir_path.iterdir() if d.is_dir()]):
49+
if should_ignore(sub, patterns):
50+
continue
51+
make_index(sub)
52+
title = sub.name.replace("_", " ").title()
53+
parts.append(f"### [{title}]({sub.name}/index.html)\n")
54+
55+
index.write_text("".join(parts), encoding="utf-8")
56+
print(f"Generated {index}")
57+
58+
59+
if __name__ == "__main__":
60+
make_index(Path("docs"))

0 commit comments

Comments
 (0)