diff --git a/i2p2www/pages/spec/show.html b/i2p2www/pages/spec/show.html index 58cc41c1..1d9cf1a6 100644 --- a/i2p2www/pages/spec/show.html +++ b/i2p2www/pages/spec/show.html @@ -3,6 +3,11 @@ {% block title %}{{ title }}{% endblock %} {% block lastupdated %}{{ meta.lastupdated }}{% endblock %} {% block accuratefor %}{{ meta.accuratefor }}{% endblock %} +{% block content_nav %} +{% autoescape false %} +{{ toc }} +{% endautoescape %} +{% endblock %} {% block content %} {% autoescape false %} {{ body }} diff --git a/i2p2www/spec/blockfile.rst b/i2p2www/spec/blockfile.rst index e529c2dd..91984e5f 100644 --- a/i2p2www/spec/blockfile.rst +++ b/i2p2www/spec/blockfile.rst @@ -5,6 +5,8 @@ Blockfile and Hosts Database Specification :lastupdated: November 2014 :accuratefor: 0.9.17 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/common-structures.rst b/i2p2www/spec/common-structures.rst index 5728da87..3ec8bd0f 100644 --- a/i2p2www/spec/common-structures.rst +++ b/i2p2www/spec/common-structures.rst @@ -5,61 +5,12 @@ Common structures Specification :lastupdated: February 2016 :accuratefor: 0.9.24 +.. contents:: + This document describes some data types common to all I2P protocols, like [I2NP]_, [I2CP]_, [SSU]_, etc. -Index -===== - -+--------------------------+ -| Type | -+==========================+ -| Boolean_ | -+--------------------------+ -| Certificate_ | -+--------------------------+ -| Date_ | -+--------------------------+ -| `Delivery Instructions`_ | -+--------------------------+ -| Destination_ | -+--------------------------+ -| Hash_ | -+--------------------------+ -| Integer_ | -+--------------------------+ -| KeysAndCert_ | -+--------------------------+ -| Lease_ | -+--------------------------+ -| LeaseSet_ | -+--------------------------+ -| Mapping_ | -+--------------------------+ -| PrivateKey_ | -+--------------------------+ -| PublicKey_ | -+--------------------------+ -| RouterAddress_ | -+--------------------------+ -| RouterIdentity_ | -+--------------------------+ -| RouterInfo_ | -+--------------------------+ -| `Session Tag`_ | -+--------------------------+ -| Signature_ | -+--------------------------+ -| PrivateKey_ | -+--------------------------+ -| SigningPublicKey_ | -+--------------------------+ -| String_ | -+--------------------------+ -| TunnelId_ | -+--------------------------+ - Common type specification ========================= diff --git a/i2p2www/spec/configuration.rst b/i2p2www/spec/configuration.rst index ebb05813..d909b050 100644 --- a/i2p2www/spec/configuration.rst +++ b/i2p2www/spec/configuration.rst @@ -5,6 +5,8 @@ Configuration File Specification :lastupdated: February 2016 :accuratefor: 0.9.25 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/cryptography.rst b/i2p2www/spec/cryptography.rst index 2ec521a7..651b5a9d 100644 --- a/i2p2www/spec/cryptography.rst +++ b/i2p2www/spec/cryptography.rst @@ -5,6 +5,8 @@ Low-level Cryptography Specification :lastupdated: December 2014 :accuratefor: 0.9.17 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/datagrams.rst b/i2p2www/spec/datagrams.rst index be29bc8b..6cd2045d 100644 --- a/i2p2www/spec/datagrams.rst +++ b/i2p2www/spec/datagrams.rst @@ -5,6 +5,8 @@ Datagram Specification :lastupdated: July 2014 :accuratefor: 0.9.14 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/geoip.rst b/i2p2www/spec/geoip.rst index c9536226..0f84e680 100644 --- a/i2p2www/spec/geoip.rst +++ b/i2p2www/spec/geoip.rst @@ -5,6 +5,8 @@ GeoIP File Specification :lastupdated: December 2013 :accuratefor: 0.9.9 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/i2cp.rst b/i2p2www/spec/i2cp.rst index ec9ea808..d01eea65 100644 --- a/i2p2www/spec/i2cp.rst +++ b/i2p2www/spec/i2cp.rst @@ -5,6 +5,8 @@ I2CP Specification :lastupdated: June 2015 :accuratefor: 0.9.21 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/i2np.rst b/i2p2www/spec/i2np.rst index 63f73cde..023a5e68 100644 --- a/i2p2www/spec/i2np.rst +++ b/i2p2www/spec/i2np.rst @@ -5,6 +5,8 @@ I2NP Specification :lastupdated: January 2016 :accuratefor: 0.9.24 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/plugin.rst b/i2p2www/spec/plugin.rst index bd432f82..2a029589 100644 --- a/i2p2www/spec/plugin.rst +++ b/i2p2www/spec/plugin.rst @@ -5,6 +5,8 @@ Plugin Specification :lastupdated: February 2016 :accuratefor: 0.9.25 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/ssu.rst b/i2p2www/spec/ssu.rst index 7ce19ad5..83d04b91 100644 --- a/i2p2www/spec/ssu.rst +++ b/i2p2www/spec/ssu.rst @@ -5,6 +5,8 @@ SSU Protocol Specification :lastupdated: November 2015 :accuratefor: 0.9.24 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/streaming.rst b/i2p2www/spec/streaming.rst index d131d8de..77b82ab5 100644 --- a/i2p2www/spec/streaming.rst +++ b/i2p2www/spec/streaming.rst @@ -5,6 +5,8 @@ Streaming Library Specification :lastupdated: June 2015 :accuratefor: 0.9.20 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/tunnel-creation.rst b/i2p2www/spec/tunnel-creation.rst index f8036807..7ba79c1a 100644 --- a/i2p2www/spec/tunnel-creation.rst +++ b/i2p2www/spec/tunnel-creation.rst @@ -5,6 +5,8 @@ Tunnel Creation Specification :lastupdated: January 2016 :accuratefor: 0.9.24 +.. contents:: + .. _tunnelCreate.overview: diff --git a/i2p2www/spec/tunnel-message.rst b/i2p2www/spec/tunnel-message.rst index 3d56d2a5..c53d3345 100644 --- a/i2p2www/spec/tunnel-message.rst +++ b/i2p2www/spec/tunnel-message.rst @@ -5,6 +5,8 @@ Tunnel Message Specification :lastupdated: February 2014 :accuratefor: 0.9.11 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/updates.rst b/i2p2www/spec/updates.rst index dd6ce4e9..5fb3c452 100644 --- a/i2p2www/spec/updates.rst +++ b/i2p2www/spec/updates.rst @@ -5,6 +5,8 @@ Software Update Specification :lastupdated: May 2015 :accuratefor: 0.9.20 +.. contents:: + Overview ======== diff --git a/i2p2www/spec/views.py b/i2p2www/spec/views.py index ca49a684..3d4393db 100644 --- a/i2p2www/spec/views.py +++ b/i2p2www/spec/views.py @@ -1,5 +1,9 @@ import codecs -from docutils.core import publish_parts +from docutils.core import ( + publish_doctree, + publish_from_doctree, + publish_parts, +) from flask import ( abort, g, @@ -13,7 +17,7 @@ from flask import ( ) import os.path -from i2p2www import SPEC_DIR +from i2p2www import PROPOSAL_DIR, SPEC_DIR from i2p2www import helpers @@ -64,6 +68,7 @@ def spec_show(name, txt=False): if txt: # Strip out RST content = content.replace('.. meta::\n', '') + content = content.replace('.. contents::\n\n', '') content = content.replace('.. raw:: html\n\n', '') content = content.replace('\n.. [', '\n[') content = content.replace(']_.', '].') @@ -81,11 +86,21 @@ def spec_show(name, txt=False): r.mimetype = 'text/plain' return r - # publish the post with docutils + # Render the ToC + doctree = publish_doctree(source=rendered_content) + bullet_list = doctree[1][1] + doctree.clear() + doctree.append(bullet_list) + toc = publish_from_doctree(doctree, writer_name='html') + + # Remove the ToC from the main document + rendered_content = rendered_content.replace('.. contents::\n', '') + + # publish the spec with docutils parts = publish_parts(source=rendered_content, source_path=SPEC_DIR, writer_name="html") meta = get_metadata_from_meta(parts['meta']) - return render_template('spec/show.html', title=parts['title'], body=parts['fragment'], name=name, meta=meta) + return render_template('spec/show.html', title=parts['title'], toc=toc, body=parts['fragment'], name=name, meta=meta) def spec_show_txt(name): return spec_show(name, True)