aboutsummaryrefslogtreecommitdiff
path: root/doc/mkdocs/build.sh
blob: 48ffbbad1a4b40333d69b3c2244e5db33651f9fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh -e

# Patch Pygments and Python-Markdown
PYGMENTS_FILE=$(pip show pygments | awk '/Location/ { print $2 }')/pygments/formatters/html.py
MARKDOWN_FILE=$(pip show markdown | awk '/Location/ { print $2 }')/markdown/extensions/codehilite.py
patch -N -r - $PYGMENTS_FILE code_tag.patch || true
patch -N -r - $MARKDOWN_FILE lua_highlight.patch || true

# Split lua_api.txt on top level headings
cat ../lua_api.txt | csplit -sz -f docs/section - '/^=/-1' '{*}'

cat > mkdocs.yml << EOF
site_name: Minetest API Documentation
theme:
    name: readthedocs
    highlightjs: False
extra_css:
    - css/code_styles.css
    - css/extra.css
markdown_extensions:
    - toc:
        permalink: True
    - codehilite
plugins:
    - search:
        separator: '[\s\-\.\(]+'
nav:
- "Home": index.md
EOF

mv docs/section00 docs/index.md

for f in docs/section*
do
	title=$(head -1 $f)
	fname=$(echo $title | tr '[:upper:]' '[:lower:]')
	fname=$(echo $fname | sed 's/ /-/g')
	fname=$(echo $fname | sed "s/'//g").md
	mv $f docs/$fname
	echo "- \"$title\": $fname" >> mkdocs.yml
done

mkdocs build --site-dir ../../public