Skip to content

Instantly share code, notes, and snippets.

@fffergal
Created December 11, 2013 00:12
Show Gist options
  • Save fffergal/7902825 to your computer and use it in GitHub Desktop.
Save fffergal/7902825 to your computer and use it in GitHub Desktop.
Sphinx extension for adding titles to autodoc classes.
from sphinx.ext.autodoc import ClassDocumenter
class TitledClassDocumenter(ClassDocumenter):
def add_directive_header(self, *args, **kwargs):
title_lines = [
self.object_name,
'=' * len(self.object_name),
'',
]
for line in title_lines:
self.add_line(line, 'Fergal being cool')
return super(TitledClassDocumenter, self).add_directive_header(
*args, **kwargs)
def setup(api):
api.add_autodocumenter(TitledClassDocumenter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment