Skip to main content

An example project generated by cookiecutter-pywf_open_source.

Project description

Documentation Status https://github.com/MacHu-GWU/rstobj-project/actions/workflows/main.yml/badge.svg https://codecov.io/gh/MacHu-GWU/rstobj-project/branch/main/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/✍️_Release_History!--None.svg?style=social&logo=github https://img.shields.io/badge/⭐_Star_me_on_GitHub!--None.svg?style=social&logo=github
https://img.shields.io/badge/Link-API-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

https://rstobj.readthedocs.io/en/latest/_static/rstobj-logo.png

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-2.0.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rstobj-2.0.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rstobj-2.0.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rstobj-2.0.0.tar.gz
Algorithm Hash digest
SHA256 56954cb767cd7de8bf4e842f6fc058211c4b197150b5d0eecf0bb10ed5321bee
MD5 b582d109eee7fc9229053404f7515ecb
BLAKE2b-256 a823b0a6883d3776b6bb826bd44a9ad3240f9487392d8f6f3ee0cd97331a05ab

See more details on using hashes here.

File details

Details for the file rstobj-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: rstobj-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rstobj-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f3d17ac9c96cc11992a27868b21e9a4379863a1793f7dcda2e649f665502af5
MD5 23f9e051dfe8fa6bcdd8c7ca27cb6393
BLAKE2b-256 5ec000b1c1a53d0cb11af9553ea071896d2241ff7ff0bc64fb7a22753657da62

See more details on using hashes here.

Supported by

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