Skip to content

Commit 66d9bcb

Browse files
committed
WIP: fixing readme gen and theming
1 parent f39f735 commit 66d9bcb

File tree

3 files changed

+63
-60
lines changed

3 files changed

+63
-60
lines changed

.github/convert.rb

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,40 +145,59 @@ def output_toc(data)
145145
categories = data['categories']
146146

147147
parents, children = categories.partition { |category| category['parent'].nil? }
148+
149+
# Use a nested list for the contents section
148150
parents.each do |parent|
149151
parent_id = parent['id']
150152
# Only include parent categories with projects or with children that have projects
151153
if has_projects_recursive(projects, categories, parent_id)
152-
output << "- [#{parent['title']}](##{parent_id})\n"
153-
154-
children.sort_by { |category| category['id'] }
155-
.select { |category| category['parent'] == parent_id }.each do |child|
156-
child_id = child['id']
154+
parent_children = children.select { |category| category['parent'] == parent_id }
155+
.sort_by { |category| category['id'] }
156+
.select { |category| has_projects_recursive(projects, categories, category['id']) }
157+
158+
# If parent has child categories with projects, make it a list item with nested items
159+
if parent_children.any?
160+
output << "- **[#{parent['title']}](##{parent_id})**\n"
157161

158-
# Only include child categories with projects or with grandchildren that have projects
159-
if has_projects_recursive(projects, categories, child_id)
160-
output << " - [#{child['title']}](##{child_id})\n"
161-
162-
children.sort_by { |category| category['id'] }
163-
.select { |category| category['parent'] == child_id }.each do |grandchild|
164-
grandchild_id = grandchild['id']
162+
# Add child categories as nested list items
163+
parent_children.each do |child|
164+
child_id = child['id']
165+
child_grandchildren = children.select { |category| category['parent'] == child_id }
166+
.sort_by { |category| category['id'] }
167+
.select { |category| has_projects_recursive(projects, categories, category['id']) }
168+
169+
# If child has grandchildren with projects, make it a list item with nested items
170+
if child_grandchildren.any?
171+
output << " - **[#{child['title']}](##{child_id})**\n"
165172

166-
# Only include grandchild categories with projects or with great-grandchildren that have projects
167-
if has_projects_recursive(projects, categories, grandchild_id)
168-
output << " - [#{grandchild['title']}](##{grandchild_id})\n"
169-
170-
children.sort_by { |category| category['id'] }
171-
.select { |category| category['parent'] == grandchild_id }.each do |great_grandchild|
172-
great_grandchild_id = great_grandchild['id']
173+
# Add grandchild categories as nested list items
174+
child_grandchildren.each do |grandchild|
175+
grandchild_id = grandchild['id']
176+
grandchild_great_grandchildren = children.select { |category| category['parent'] == grandchild_id }
177+
.sort_by { |category| category['id'] }
178+
.select { |category| has_projects(projects, category['id']) }
179+
180+
# If grandchild has great-grandchildren with projects, make it a list item with nested items
181+
if grandchild_great_grandchildren.any?
182+
output << " - **[#{grandchild['title']}](##{grandchild_id})**\n"
173183

174-
# Only include great-grandchild categories with projects
175-
if has_projects(projects, great_grandchild_id)
176-
output << " - [#{great_grandchild['title']}](##{great_grandchild_id})\n"
184+
# Add great-grandchild categories as nested list items
185+
grandchild_great_grandchildren.each do |great_grandchild|
186+
output << " - [#{great_grandchild['title']}](##{great_grandchild['id']})\n"
177187
end
188+
else
189+
# Grandchild has no children, so it's a simple list item
190+
output << " - [#{grandchild['title']}](##{grandchild_id})\n"
178191
end
179192
end
193+
else
194+
# Child has no grandchildren, so it's a simple list item
195+
output << " - [#{child['title']}](##{child_id})\n"
180196
end
181197
end
198+
else
199+
# Parent has no children, so it's a simple list item
200+
output << "- [#{parent['title']}](##{parent_id})\n"
182201
end
183202
end
184203
end

.github/workflows/build-deploy.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
branches:
55
- master
6+
paths-ignore:
7+
- 'README.md' # Ignore README.md changes to prevent infinite loops
68
env:
79
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
810
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
@@ -51,17 +53,30 @@ jobs:
5153
with:
5254
python-version: 3.9
5355
- uses: actions/checkout@v4
54-
- name: run README.md gen
56+
with:
57+
token: ${{ secrets.PERSONAL_TOKEN }}
58+
- name: Generate README.md from contents.json
5559
run: ruby .github/convert.rb
56-
- name: run database.json gen
60+
- name: Commit README.md back to master if it changed
61+
run: |
62+
git config --global user.name 'GitHub Action'
63+
git config --global user.email 'action@github.com'
64+
git add README.md
65+
if git diff --cached --exit-code; then
66+
echo "No changes to README.md"
67+
else
68+
git commit -m "[ci skip] Auto-update README.md from contents.json"
69+
git push
70+
fi
71+
- name: Generate database.json
5772
run: node .github/upgradeDb.js
58-
- name: install mkdoc build deps
73+
- name: Install mkdocs build dependencies
5974
run: sudo apt-get update && sudo apt-get -y install lsb-release unzip python3-pip python3-dev && pip3 install mkdocs mkdocs-material pymdown-extensions mkdocs-minify-plugin json-spec
60-
- name: use makefile to install all deps to ensure we have the same versions
75+
- name: Install all dependencies via makefile
6176
run: make site_install
62-
- name: use makefile to install all deps to ensure we have the same versions
77+
- name: Build MkDocs site
6378
run: make site_build
64-
- name: Deploy docs
79+
- name: Deploy docs to GitHub Pages
6580
uses: mhausenblas/mkdocs-deploy-gh-pages@master
6681
with:
6782
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

mkdocs.yml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,6 @@ theme:
1313
font:
1414
text: 'Menlo, DejaVu Sans Mono, Consolas, Lucida Console, monospace'
1515
code: 'Menlo, DejaVu Sans Mono, Consolas, Lucida Console, monospace'
16-
features:
17-
- navigation.instant
18-
- navigation.tracking
19-
- navigation.top
20-
- navigation.sections
21-
- navigation.expand
22-
- navigation.indexes
23-
- toc.integrate
24-
- header.autohide
25-
- search.highlight
26-
- content.code.copy
27-
icon:
28-
repo: fontawesome/brands/github
29-
logo: false
30-
favicon: false
31-
markdown_extensions:
32-
- pymdownx.highlight:
33-
anchor_linenums: true
34-
line_spans: __span
35-
pygments_lang_class: true
36-
- pymdownx.inlinehilite
37-
- pymdownx.snippets
38-
- pymdownx.superfences
39-
- admonition
40-
- tables
41-
- toc:
42-
permalink: true
43-
plugins:
44-
- search
45-
- minify:
46-
minify_html: true
4716
extra:
4817
analytics:
4918
provider: google
@@ -58,4 +27,4 @@ extra:
5827
extra_css:
5928
- css/extra.css
6029
nav:
61-
- "From FFMPEG to playback, streaming video.": "index.md"
30+
- "From FFMPEG to playback, streaming video.": "index.md"

0 commit comments

Comments
 (0)