sphinxnotes-data

Documentation Status Open Source License PyPI Package PyPI Package Downloads GitHub Repository

Introduction

Define, constrain, and render data in Sphinx documentation.

This is a POC (Proof of Concept) of the sphinxnotes.render extension.

Getting Started

Note

We assume you already have a Sphinx documentation, if not, see Getting Started with Sphinx.

First, downloading extension from PyPI:

$ pip install sphinxnotes-data

Then, add the extension name to extensions configuration item in your conf.py:

extensions = [
          # …
          'sphinxnotes.data',
          # …
          ]

Before defining any data, we need to create template using the data:template directive, to tell extension how to render the data:

.. data:template::

  The data is named "{{ name }}", and has the following attributes:

  {% for k, v in attrs.items() %}
  :{{ k }}: {{ v }}
  {%- endfor %}

  The following is the content of the data:

     {{ content }}

The above template will not change the document and will just create a temporary template for later use.

We can define data now, using a data:define directive.

Source
.. data:define:: Shengyu Zhang
   :github: SilverRainZ
   :homepage: https://silverrainz.me/

   I love Swan.
Result

The data is named “Shengyu Zhang”, and has the following attributes:

github:

SilverRainZ

homepage:

https://silverrainz.me/

The following is the content of the data:

I love Swan.

Hint

Unlike ordinary directives, the data:define accepts any options. For example, neither “github” nor “homepage” is pre-defined.

For details, see Usage.

Contents

The Sphinx Notes Project

The project is developed by Shengyu Zhang, as part of The Sphinx Notes Project.

The Sphinx Notes Project