Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved theming to documentation site with added search plugin #47

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions docs/api/make-docs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# The following npm packages must be installed
# docsify-cli docsify-themeable [email protected] katex marked@4

# To customise the theme see:
# https://jhildenbiddle.github.io/docsify-themeable/#/customization

set -e

if [ "$(basename $(pwd))" != "api" ]; then
Expand All @@ -16,6 +22,7 @@ fi

docsify init --local "$destdir"

rm -Rf "$destdir"/vendor/themes
rm -f "$destdir"/README.md

if [ -n "$NPM_PACKAGES" ]; then
Expand All @@ -31,7 +38,16 @@ else
exit 1
fi

cp $npm_dir/docsify/node_modules/prismjs/components/prism-{json,python}.min.js "$destdir"/vendor
cp $npm_dir/docsify/lib/plugins/search.min.js "$destdir"/vendor
cp $npm_dir/prismjs/components/prism-{json,python,http}.min.js "$destdir"/vendor
cp $npm_dir/docsify-themeable/dist/css/theme-simple.css "$destdir"/vendor
cp $npm_dir/docsify-themeable/dist/css/theme-simple-dark.css "$destdir"/vendor
cp $npm_dir/docsify-themeable/dist/js/docsify-themeable.min.js "$destdir"/vendor
cp $npm_dir/marked/marked.min.js "$destdir"/vendor
cp $npm_dir/katex/dist/katex.min.js "$destdir"/vendor
cp $npm_dir/katex/dist/katex.min.css "$destdir"/vendor
cp -R $npm_dir/katex/dist/fonts "$destdir"/vendor
cp $npm_dir/docsify-katex/dist/docsify-katex.js "$destdir"/vendor

./api-to-markdown.py --out="$destdir" "$@"

Expand All @@ -48,16 +64,35 @@ if (m{^\s*<script>\s*$} .. m{^\s*</script>\s*$}) {
loadSidebar: "sidebar.md",
subMaxLevel: 2,
homepage: "index.md",
themeable: {
readyTransition : true, // default
responsiveTables: true // default
}
}
</script>\n};
}
} else {
s{<title>.*</title>}{<title>Libsession Utils API</title>};
s{(name="description" content=)"[^"]*"}{$1"libsession-util function documentation"};
s{^\s*<link rel="stylesheet" href="vendor/themes/vue.css">\s*$}{};
if (m{^\s*</body>}) {
print qq{
<link rel="stylesheet" href="vendor/katex.min.css" />
<link rel="stylesheet" media="(prefers-color-scheme: light)" href="vendor/theme-simple.css">
<link rel="stylesheet" media="(prefers-color-scheme: dark)" href="vendor/theme-simple-dark.css">
<style>
:root {
--content-max-width : 1100px;
}
</style>
<script src="vendor/search.min.js"></script>
<script src="vendor/prism-json.min.js"></script>
<script src="vendor/prism-python.min.js"></script>\n};
<script src="vendor/prism-python.min.js"></script>
<script src="vendor/prism-http.min.js"></script>
<script src="vendor/marked.min.js"></script>
<script src="vendor/katex.min.js"></script>
<script src="vendor/docsify-katex.js"></script>
<script src="vendor/docsify-themeable.min.js"></script>\n};
}
print;
}' "$destdir"/index.html