~cypheon/idris2-quickdocs

ded2884cfcada6badc28d7b74fc604975c72edbc — Johann Rudloff 1 year, 5 months ago ad31d0a
Generate a homepage with basic introduction
6 files changed, 200 insertions(+), 1 deletions(-)

A mkhome.py
M poetry.lock
M pyproject.toml
A rebuild_all.sh
M style.css
A templates/home.md.j2
A mkhome.py => mkhome.py +40 -0
@@ 0,0 1,40 @@
#!/usr/bin/env python3

from pathlib import Path
import sys

from jinja2 import Template
import markdown

HTML_HEADER = ''' <!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><title>Idris2 Docs</title><link rel="stylesheet" href="../style.css"></head><body class="nodebug"><article class="copy">
'''
HTML_TRAILER = '''</article></body></html>'''

def main():
    root = Path(sys.argv[1])
    with open('templates/home.md.j2') as f:
        tpl = Template(f.read())

    packages = []
    downloads = []
    for pkg in sorted(root.glob('*/index.html')):
        link = pkg.relative_to(root)
        pkg = link.parts[-2]
        packages.append(pkg)
        dlfilename = pkg + '-idris2docs.tar.gz'
        downloads.append(dlfilename)

    context = {
        'packages': packages,
        'downloads': downloads,
    }

    with open(root / 'home.html', 'w') as f:
        f.write(HTML_HEADER)
        md = tpl.render(**context)
        f.write(markdown.markdown(md))
        f.write(HTML_TRAILER)

if __name__ == '__main__':
    main()

M poetry.lock => poetry.lock +77 -1
@@ 17,6 17,39 @@ lxml = ["lxml"]

[[package]]
category = "main"
description = "A very fast and expressive template engine."
name = "jinja2"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "2.11.2"

[package.dependencies]
MarkupSafe = ">=0.23"

[package.extras]
i18n = ["Babel (>=0.8)"]

[[package]]
category = "main"
description = "Python implementation of Markdown."
name = "markdown"
optional = false
python-versions = ">=3.6"
version = "3.3.3"

[package.extras]
testing = ["coverage", "pyyaml"]

[[package]]
category = "main"
description = "Safely add untrusted strings to HTML/XML markup."
name = "markupsafe"
optional = false
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*"
version = "1.1.1"

[[package]]
category = "main"
description = "A modern CSS selector implementation for Beautiful Soup."
marker = "python_version >= \"3.0\""
name = "soupsieve"


@@ 25,7 58,7 @@ python-versions = ">=3.5"
version = "2.1"

[metadata]
content-hash = "0aed234b5ffb3d308de24294c6b9d687f1f61ff50711eea9cb63a07a57074644"
content-hash = "c19180e68458b4b2cb7059789a7f724f1c5c63d820a33ed80c7fedddbe5e55ec"
python-versions = "^3.8"

[metadata.files]


@@ 34,6 67,49 @@ beautifulsoup4 = [
    {file = "beautifulsoup4-4.9.3-py3-none-any.whl", hash = "sha256:fff47e031e34ec82bf17e00da8f592fe7de69aeea38be00523c04623c04fb666"},
    {file = "beautifulsoup4-4.9.3.tar.gz", hash = "sha256:84729e322ad1d5b4d25f805bfa05b902dd96450f43842c4e99067d5e1369eb25"},
]
jinja2 = [
    {file = "Jinja2-2.11.2-py2.py3-none-any.whl", hash = "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035"},
    {file = "Jinja2-2.11.2.tar.gz", hash = "sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0"},
]
markdown = [
    {file = "Markdown-3.3.3-py3-none-any.whl", hash = "sha256:c109c15b7dc20a9ac454c9e6025927d44460b85bd039da028d85e2b6d0bcc328"},
    {file = "Markdown-3.3.3.tar.gz", hash = "sha256:5d9f2b5ca24bc4c7a390d22323ca4bad200368612b5aaa7796babf971d2b2f18"},
]
markupsafe = [
    {file = "MarkupSafe-1.1.1-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161"},
    {file = "MarkupSafe-1.1.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"},
    {file = "MarkupSafe-1.1.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183"},
    {file = "MarkupSafe-1.1.1-cp27-cp27m-win32.whl", hash = "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b"},
    {file = "MarkupSafe-1.1.1-cp27-cp27m-win_amd64.whl", hash = "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e"},
    {file = "MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f"},
    {file = "MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1"},
    {file = "MarkupSafe-1.1.1-cp34-cp34m-macosx_10_6_intel.whl", hash = "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5"},
    {file = "MarkupSafe-1.1.1-cp34-cp34m-manylinux1_i686.whl", hash = "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1"},
    {file = "MarkupSafe-1.1.1-cp34-cp34m-manylinux1_x86_64.whl", hash = "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735"},
    {file = "MarkupSafe-1.1.1-cp34-cp34m-win32.whl", hash = "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21"},
    {file = "MarkupSafe-1.1.1-cp34-cp34m-win_amd64.whl", hash = "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235"},
    {file = "MarkupSafe-1.1.1-cp35-cp35m-macosx_10_6_intel.whl", hash = "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b"},
    {file = "MarkupSafe-1.1.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f"},
    {file = "MarkupSafe-1.1.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905"},
    {file = "MarkupSafe-1.1.1-cp35-cp35m-win32.whl", hash = "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1"},
    {file = "MarkupSafe-1.1.1-cp35-cp35m-win_amd64.whl", hash = "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d"},
    {file = "MarkupSafe-1.1.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff"},
    {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473"},
    {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e"},
    {file = "MarkupSafe-1.1.1-cp36-cp36m-win32.whl", hash = "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66"},
    {file = "MarkupSafe-1.1.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5"},
    {file = "MarkupSafe-1.1.1-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d"},
    {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e"},
    {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"},
    {file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"},
    {file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"},
    {file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"},
    {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"},
    {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"},
    {file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"},
    {file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"},
    {file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"},
]
soupsieve = [
    {file = "soupsieve-2.1-py3-none-any.whl", hash = "sha256:4bb21a6ee4707bf43b61230e80740e71bfe56e55d1f1f50924b087bb2975c851"},
    {file = "soupsieve-2.1.tar.gz", hash = "sha256:6dc52924dc0bc710a5d16794e6b3480b2c7c08b07729505feab2b2c16661ff6e"},

M pyproject.toml => pyproject.toml +2 -0
@@ 7,6 7,8 @@ authors = ["Johann Rudloff <johann@sinyax.net>"]
[tool.poetry.dependencies]
python = "^3.8"
beautifulsoup4 = "^4.9.3"
markdown = "^3.3.3"
jinja2 = "^2.11.2"

[tool.poetry.dev-dependencies]


A rebuild_all.sh => rebuild_all.sh +31 -0
@@ 0,0 1,31 @@
#!/usr/bin/env bash

set -e
set -u
set -o pipefail
set -x

src_root=${IDRIS2_SRC:-$PWD/../mkdocs}
idris2=${IDRIS2_EXECUTABLE:-$PWD/../mkdocs/build/exec/idris2}

build_doc() {
  pkg="$1"
  (
    cd "${src_root}/libs/$pkg"
    rm -rf build/docs
    "$idris2" --mkdoc "${pkg}.ipkg"
  )

  rm -rf "data/${pkg}"

  mkdir -p data
  cp -av "${src_root}/libs/${pkg}/build/docs" "data/${pkg}"
  ( cd data && tar czf "${pkg}-idris2docs.tar.gz" "$pkg")
}

for pkg in base contrib network prelude; do
  build_doc "$pkg"
done

poetry run ./mkindex.py data
poetry run ./mkhome.py data

M style.css => style.css +18 -0
@@ 93,6 93,24 @@
  background-color: rgb(101, 159, 219);
}

article.copy {
  margin: 3em auto;
  width: 680px;
}
 article.copy code {
   background-color: #eeeeee;
   border: 1px solid #dddddd;
   border-radius: 2px;
   padding: 1px 0.4em;
 }

@media(max-width: 720px) {
  article.copy {
    margin: 3em 1em;
    width: auto;
  }
}

html, body {
  margin: 0;
  height: 100%;

A templates/home.md.j2 => templates/home.md.j2 +32 -0
@@ 0,0 1,32 @@
# Idris2 Documentation

Use the search field on the left to perform a search, results will update as
you type.

### Fuzzy Search Patterns

You can use dots to quickly skip over namespaces, e.g. enter `C.M.S.run` to
find `Control.Monad.State.runState`

### Available Packages

{% for pkg in packages %} * [{{ pkg }}]({{ pkg }}/index.html)
{% endfor %}

### Downloads

Each `tar.gz` contains self-contained HTML for offline viewing (but without
"quick search" capability):

{% for dl in downloads %} * [{{ dl }}]({{ dl }})
{% endfor %}

### Source Code

#### Idris2 branch with `--mkdoc` support
available at:
<a href="https://github.com/cypheon/Idris2/tree/mkdoc" target="_blank">https://github.com/cypheon/Idris2/tree/mkdoc</a>

#### Index Builder and Search JavaScript
available at:
<a href="https://git.sr.ht/~cypheon/idris2-quickdocs" target="_blank">https://git.sr.ht/~cypheon/idris2-quickdocs</a>