Sphinx + autodoc + apidoc

Ned Batchelder ned at nedbatchelder.com
Mon Oct 24 17:39:40 EDT 2016


On Monday, October 24, 2016 at 5:00:47 PM UTC-4, Dan Stromberg wrote:
> Hi folks.
> 
> I'm attempting to set up Sphinx to document several API's based on docstrings.
> 
> I've got something browseable for one example API using Sphinx +
> autodoc + apidoc.
> 
> However, we aren't really a PEP8 shop; we use hard tabs expanded to 4
> columns, and we use 120 columns total width (and sometimes a little
> more :).
> 
> I'd love to switch to spaces, but it's not my decision, so...  And
> it's hard for me to imagine going back to 80 columns - it's so
> confining, especially when you use good, descriptive identifiers.
> 
> Anyway, in the Sphinx pages that say "Source code for <modulename>",
> and that show every line of the particular python module (syntax
> highlighted), the tabs are all expanded to 8 columns, and the total
> width is 80 columns.  I can scroll around to see everything, but it's
> a little like looking at a football field through a microscope.
> 
> Is there any good way of making Sphinx use 4 column tabs and 120 column text?
> 
> I can imagine recursively applying *ix "expand -4" to the .py files to
> get a for-doc-only tree before passing them to Sphinx, but what about
> the 80 column limit?  And is there a nicer way of dealing with the tab
> situation?
> 
> I googled quite a bit, and found some stuff suggesting that the Sphinx
> devs would be OK with doing hard tabs, but Sphinx depends on Docutils,
> and the Docutils project is perhaps more into PEP8.

Are you sure your tabs are being changed to eight spaces? It's possible they
are still tabs in the browser, and the browser is choosing to display them
as eight spaces. If that's the case, you can change the width using CSS in
the theme.  Likely the page width of 80 characters is also manipulable with
CSS.

--Ned.



More information about the Python-list mailing list