rst2pdf/rst2pdf

support `.. include:: file.py` with `:code: python`

habamax opened this issue · 1 comments

Currently if I include a file using:

test.rst

Include Example
===============

.. include:: test.py
  :code: python

test.py

def hello_world():
    """Doc string"""
    print("Hello World!")

Result using rst2html is

image

Result of rst2pdf is

image

Description of problem

I know there is

.. code-block:: python
  :include: test.py

That works just fine

image

but unfortunately docutils doesn't support code-block.

For now I just have two versions for each included file in my documents and do bulk comment/uncomment depending on media type I am to export to.

It would be really nice if rst2pdf could work with .. include:: ...\n :code: lang as well.

🖥 Versions

python -V: 3.11.2

pip freeze | grep rst2pdf: 0.101

pip freeze | grep reportlab: 4.1.0

Which operating system are you using?

Debian bookworm

Thanks for the suggestion, I'd be very happy to review pull requests on this if anyone has time to work on it.