Skip to main content

Construct RestructuredText markup and directives from Python Code.

Project description

Documentation Status https://github.com/MacHu-GWU/rstobj-project/workflows/CI/badge.svg https://codecov.io/gh/MacHu-GWU/rstobj-project/branch/master/graph/badge.svg https://img.shields.io/pypi/v/rstobj.svg https://img.shields.io/pypi/l/rstobj.svg https://img.shields.io/pypi/pyversions/rstobj.svg https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social
https://img.shields.io/badge/Link-Document-blue.svg https://img.shields.io/badge/Link-API-blue.svg https://img.shields.io/badge/Link-Source_Code-blue.svg https://img.shields.io/badge/Link-Install-blue.svg https://img.shields.io/badge/Link-GitHub-blue.svg https://img.shields.io/badge/Link-Submit_Issue-blue.svg https://img.shields.io/badge/Link-Request_Feature-blue.svg https://img.shields.io/badge/Link-Download-blue.svg

Welcome to rstobj Documentation

rstobj is a library that construct Restructured Text markup or directives from Python Code. rstobj is based on jinja2.

The idea behind rstobj:

RestructuredText is super powerful, way more powerful than markdown. But have you ever think of customize YOUR OWN markup or directive and do some magic?

Have you think of automatically generate customized document from your code or tabulate data?

Sphinx Doc is the ultimate doc build tool. With rstobj, you can easily create your own markup / directive, and hide complex workflow behind a single markup / directive, then use it when you need it. Here’s some ideas:

  1. Use .. include-all-image:: to automatically scan image file under a directory, create .. image:: directive and organize everything in a table.

  2. Separate comment and value of the config file, automatically create an document for a config file.

I have a Blog Post to share how to create a sphinx doc extension in 50 lines and customize your own directive (Sorry, its written in Chinese).

Example:

import rstobj # or from rstobj import *

header = rstobj.markup.Header(title="Section1", header_level=1, auto_label=True)
rst_header = header.render()
print(rst_header)

ltable = rstobj.directives.ListTable(
    data=[["id", "name"], [1, "Alice"], [2, "Bob"]],
    title="Users",
    header=True,
)
rst = ltable.render()
print(rst_ltable)

Output:

.. _section1:

Section1
========

.. list-table:: Users
    :header-rows: 1
    :stub-columns: 0

    * - id
      - name
    * - 1
      - Alice
    * - 2
      - Bob

I recommend to use this in your jinja2 template, content of outut.rst:

{{ header.render() }}
{{ ltable.render() }}

And use rstobj with sphinx-jinja library https://pypi.org/project/sphinx-jinja/ in sphinx doc project.

Supported directives:

  • .. image::

  • .. list-table::

  • .. contents::

  • .. code-block::

  • .. include::

Supported markup:

  • Header:

    .. _ref-label:
    
    Title
    =====
  • URL: `Text <Target>`_

  • Reference: :ref:`Text <Target>`

If you need more features, please submit an issue to https://github.com/MacHu-GWU/rstobj-project/issues

Install

rstobj is released on PyPI, so all you need is:

$ pip install rstobj

To upgrade to latest version:

$ pip install --upgrade rstobj

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rstobj-1.2.1.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

rstobj-1.2.1-py2.py3-none-any.whl (28.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rstobj-1.2.1.tar.gz.

File metadata

  • Download URL: rstobj-1.2.1.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for rstobj-1.2.1.tar.gz
Algorithm Hash digest
SHA256 d7ca0a496f86cfc67ebcdb065b22043ad56b6ff53b63bc45abfd8d7864efe42a
MD5 57a50ffdbbbab1d246396d3b71ccbec8
BLAKE2b-256 8700c20e9c22f1a022c5def19fc95d2434b599df435cffa38a251777379ef85e

See more details on using hashes here.

File details

Details for the file rstobj-1.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: rstobj-1.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for rstobj-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a7456f726c09572a13d6e66873d7764bc5324d0b6c3e8099f1672cacc2476f27
MD5 4cd58787c1c17101adbb217d20ece0ac
BLAKE2b-256 6ab4b7d1d3b1841ac896c1fa0e3fc9409c7cc0e321f0224ed67517f68ec46d97

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page