Search code examples
python-sphinxrinohtype

Code documentation with Sphinx and RinohType only on the right third of the page


I'm struggling with the formatting of the RinohType generated PDF document of my code documentation. How can I change the format of the PDF document for the following example.

Everything of the class description is on the right side to the constructor's definition.

image of PDF


Solution

  • This was caused by recent changes to how objects with labels are rendered. The Sphinx style sheet was adjusted to fix this in rinohtype 0.5.2 (thanks to you pointing out this issue!).

    If you can't upgrade to 0.5.2, you can fix this by extending the style sheet and overriding the label_max_width style property for the object description style. A value of none places no limits on the label width and will always render the description to the right. Setting label_max_width to a dimension will force the the description to be rendered below the label if it exceeds the specified width.

    mystyle.rts:

    [STYLESHEET]
    name=MyStyle
    base=sphinx
    
    [object description]
    label_max_width=10pt
    

    To instruct rinohtype to use this style sheet, you first need to create a template configuration file that references it:

    mytemplate.rtt:

    [TEMPLATE_CONFIGURATION]
    name = my template configuration
    template = book
    stylesheet = mystyle.rts
    

    Finally, reference this template configuration file from rinoh_documents in your project's conf.py:

    rinoh_documents = [
        dict(doc='index', target='manual', template='mytemplate.rtt'),
    ]