reStructuredText
— it is a file format for text data that is mainly used by Python-based communities to develop documentation in a simple way similar to other tools like Javadoc for Java. Most Python-based software and library documents are written using reStructuredText, and therefore important to study when working in any organization.
Like Python, RST syntax is also sensitive to indentation.
Sample reStructuredText code:
Some basic HTML syntax and rendering are shown below.
usage | syntax | HTML rendering |
---|---|---|
Heading | ***** Heading ***** | Heading |
italic | * italic * | italic |
bold | ** bold ** | bold |
link | ’gfg "python.engineering" ’ | |
verbatim | ’’ Some text or code’’ | Some text or code
|
restructured.rst
|
Save the file with the extension .rst .
Python code:
Below is the Python code for converting files. rst to HTML files. docutils
— it is a predefined library loaded during Python installation. The publish_file
method is used to convert the first to HTML, passing the filenames as parameters.
|
output.html
After running the Python code, the HTML file will be generated in the same directory as as the first file. HTML is more complex than normal human-written HTML because it is generated automatically. The following image shows the HTML rendering of the reStructuredText shown above.