aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2017-01-26 18:52:54 +0100
committernodiscc <nodiscc@gmail.com>2017-06-18 00:19:49 +0200
commit53ed6d7d1e678d7486337ce67a2f17b30bac21ac (patch)
treef8bef0164a70bd03d2b9781951c01bdd018f1842 /Makefile
parentd5d22a6d07917865c44148ad76f43c65a929a890 (diff)
downloadShaarli-53ed6d7d1e678d7486337ce67a2f17b30bac21ac.tar.gz
Shaarli-53ed6d7d1e678d7486337ce67a2f17b30bac21ac.tar.zst
Shaarli-53ed6d7d1e678d7486337ce67a2f17b30bac21ac.zip
Generate HTML documentation using MkDocs (WIP)
MkDocs is a static site generator geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML file. * http://www.mkdocs.org/ * http://www.mkdocs.org/user-guide/configuration/ Ref. #312 * remove pandoc-generated HTML documentation * move markdown doc to doc/md/, * mkdocs.yml: * generate HTML doc in doc/html * add pages TOC/ordering * use index.md as index page * Makefile: remove execute permissions from generated files * Makefile: rewrite htmlpages GFM to markdown conversion using sed: awk expression aslo matched '][' which causes invalid output on complex links with images or code blocks * Add mkdocs.yml to .gitattributes, exclude this file from release archives * Makefile: rename: htmldoc -> doc_html target * run make doc: pull latest markdown documentation from wiki * run make htmlpages: update html documentation
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile52
1 files changed, 19 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 1d8a73a2..1ddd60f8 100644
--- a/Makefile
+++ b/Makefile
@@ -194,42 +194,28 @@ doxygen: clean
194 194
195### update the local copy of the documentation 195### update the local copy of the documentation
196doc: clean 196doc: clean
197 @rm -rf doc 197 @rm -rf doc/md/
198 @git clone https://github.com/shaarli/Shaarli.wiki.git doc 198 @git clone https://github.com/shaarli/Shaarli.wiki.git doc/md
199 @rm -rf doc/.git 199 mv doc/md/Home.md doc/md/index.md
200 200 @rm -rf doc/md/.git
201### Generate a custom sidebar
202#
203# Sidebar content:
204# - convert GitHub-flavoured relative links to standard Markdown
205# - trim HTML, only keep the list (<ul>[...]</ul>) part
206htmlsidebar:
207 @echo '<div id="local-sidebar">' > doc/sidebar.html
208 @awk 'BEGIN { FS = "[\\[\\]]{2}" }'\
209 'm = /\[/ { t=$$2; gsub(/ /, "-", $$2); print $$1"["t"]("$$2".html)"$$3 }'\
210 '!m { print $$0 }' doc/_Sidebar.md > doc/tmp.md
211 @pandoc -f markdown -t html5 -s doc/tmp.md | awk '/(ul>|li>)/' >> doc/sidebar.html
212 @echo '</div>' >> doc/sidebar.html
213 @rm doc/tmp.md
214 201
215### Convert local markdown documentation to HTML 202### Convert local markdown documentation to HTML
216# 203#
217# For all pages: 204# For all pages:
218# - infer title from the file name
219# - convert GitHub-flavoured relative links to standard Markdown 205# - convert GitHub-flavoured relative links to standard Markdown
220# - insert the sidebar menu 206# - generate html documentation with mkdocs
221htmlpages: 207htmlpages:
222 @for file in `find doc/ -maxdepth 1 -name "*.md"`; do \ 208 # Rename local [[links]] to regular links.
223 base=`basename $$file .md`; \ 209 @for file in `find doc/md/ -maxdepth 1 -name "*.md"`; do \
224 sed -i "1i #$${base//-/ }" $$file; \ 210 sed -e "s/\[\[\(.*\)\]\]/[\1](\1)/g" "$$file" > doc/md/tmp.md; \
225 awk 'BEGIN { FS = "[\\[\\]]{2}" }'\ 211 mv doc/md/tmp.md $$file; \
226 'm = /\[/ { t=$$2; gsub(/ /, "-", $$2); print $$1"["t"]("$$2".html)"$$3 }'\ 212 done
227 '!m { print $$0 }' $$file > doc/tmp.md; \ 213
228 mv doc/tmp.md $$file; \ 214 python3 -m venv venv/
229 pandoc -f markdown_github -t html5 -s \ 215 bash -c 'source venv/bin/activate; \
230 -c "github-markdown.css" \ 216 pip install mkdocs; \
231 -T Shaarli -M pagetitle:"$${base//-/ }" -B doc/sidebar.html \ 217 mkdocs build'
232 -o doc/$$base.html $$file; \ 218 find doc/html/ -type f -exec chmod a-x '{}' \;
233 done; 219 rm -r venv
234 220
235htmldoc: authors doc htmlsidebar htmlpages 221doc_html: authors doc htmlpages