1717import sys
1818
1919import django
20- import sphinx_rtd_theme
2120from django .utils .encoding import force_text
2221from django .utils .html import strip_tags
2322
5150files .FileDescriptor .__get__ = lambda * args : None
5251
5352
54- # Auto list fields from django models - from https://djangosnippets.org/snippets/2533/#c5977
53+ # Auto list fields from django models
54+ # from https://djangosnippets.org/snippets/2533/#c5977
5555def process_docstring (app , what , name , obj , options , lines ):
5656 # This causes import errors if left outside the function
5757 from django .db import models
@@ -62,7 +62,8 @@ def process_docstring(app, what, name, obj, options, lines):
6262 fields = obj ._meta .get_fields ()
6363
6464 for field in fields :
65- # Skip ManyToOneRel and ManyToManyRel fields which have no 'verbose_name' or 'help_text'
65+ # Skip ManyToOneRel and ManyToManyRel fields
66+ # which have no 'verbose_name' or 'help_text'
6667 if not hasattr (field , 'verbose_name' ):
6768 continue
6869
@@ -85,9 +86,15 @@ def process_docstring(app, what, name, obj, options, lines):
8586 # Add the field's type to the docstring
8687 if isinstance (field , models .ForeignKey ):
8788 to = field .remote_field .model
88- lines .append (u':type %s: %s to :class:`~%s`' % (field .attname , type (field ).__name__ , to ))
89+ lines .append (
90+ u':type %s: %s to :class:`~%s`'
91+ % (field .attname , type (field ).__name__ , to )
92+ )
8993 else :
90- lines .append (u':type %s: %s' % (field .attname , type (field ).__name__ ))
94+ lines .append (
95+ u':type %s: %s'
96+ % (field .attname , type (field ).__name__ )
97+ )
9198
9299 return lines
93100
@@ -96,14 +103,14 @@ def process_docstring(app, what, name, obj, options, lines):
96103
97104# Add any Sphinx extension module names here, as strings. They can be
98105# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
99- extensions = ["sphinx.ext.autodoc" , "sphinx.ext.viewcode" , "m2r" ]
106+ extensions = ["sphinx.ext.autodoc" , "sphinx.ext.viewcode" ]
100107
101108# Add any paths that contain templates here, relative to this directory.
102109templates_path = ['_templates' ]
103110
104111# The suffix(es) of source filenames.
105112# You can specify multiple suffix as a list of string:
106- source_suffix = [".rst" , ".md" ]
113+ source_suffix = [".rst" ]
107114
108115# The master toctree document.
109116master_doc = 'index'
@@ -168,18 +175,11 @@ def process_docstring(app, what, name, obj, options, lines):
168175# html_theme = 'default'
169176
170177html_theme = "sphinx_rtd_theme"
171- html_theme_path = ["." , sphinx_rtd_theme .get_html_theme_path ()]
172178
173179
174- # Approach 2 for custom stylesheet:
175- # adapted from: http://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html
176- # and https://github.com/altair-viz/altair/pull/418/files
177- # https://github.com/rtfd/sphinx_rtd_theme/issues/117
178180def setup (app ):
179181 # Register the docstring processor with sphinx
180182 app .connect ("autodoc-process-docstring" , process_docstring )
181- # Add our custom CSS overrides
182- app .add_css_file ("theme_overrides.css" )
183183
184184
185185# Theme options are theme-specific and customize the look and feel of a
0 commit comments