avatarLaxfed Paulacy

Summarize

PYTHON — Python Markup with reStructuredText

The most dangerous phrase in the language is, ‘We’ve always done it this way.’ — Grace Hopper

Insights in this article were refined using prompt engineering methods.

PYTHON — k-NN Data Fitting and Prediction in Python

# Customizing Your Documentation With RST Markup

In this article, we will dive into reStructuredText (RST), the default markup language used by Sphinx for customizing documentation. RST is a text-based format where specific symbols provide style and structure to the document. If you’ve used Markdown or asciidoc before, RST will feel familiar.

Styling Text

Styling within a paragraph is achieved through special characters.

Italics

To italicize text, use paired asterisks:

*italicized text*

Bold

For bold text, use paired double asterisks:

**bold text**

Code

Display code using double backticks:

`` `code snippet` ``

Inline Code Blocks

For inline code blocks, use double backticks. The result is typically rendered in a monospace font.

Line Separator

You can add a line separator between paragraphs by using any punctuation more than four times in a row. Dash (-) is commonly used for this purpose.

Headings and Lists

Headings

Headings are created using specific markers. The first heading marker determines the title style. For example:

Title
-----
Subtitle

Note: The style used for headings may vary, but consistency is important.

Lists

  • Bulleted lists are represented using asterisks:
* Item 1
* Item 2
  • Numbered lists can be explicit or automatic:
# Item 1
# Item 2

Links

  • External links are represented using single backticks and an underscore suffix. For example:
`link name <https://www.example.com>`_
  • Internal links utilize double dots, an underscore prefix, and a single colon.
:ref:`reference name <link>`

Directives

Directives are blocks of instructions used for structure and styling. They start with double leading dots (..) and are marked with a double colon (::).

.. directive_name::
   :option: value
   content

Common directives include code-block for displaying code, image for embedding images, note and warning for callout boxes, and include for embedding files.

Conclusion

In this tutorial, we have explored the basics of customizing documentation with RST markup. This is just a glimpse of what you can achieve with Sphinx and RST. By mastering these techniques, you can effectively create well-structured, visually appealing documentation for your Python projects.

For more advanced features and details, it is recommended to refer to the official reStructuredText documentation.

PYTHON — Appending File in Python

ChatGPT
Markup
Python
Restructuredtext
Recommended from ReadMedium