3434# If your documentation needs a minimal Sphinx version, state it here.
3535# needs_sphinx = '1.0'
3636
37- autoclass_content = ' both'
37+ autoclass_content = " both"
3838
3939# Add any Sphinx extension module names here, as strings. They can be
4040# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4141# ones.
42- extensions = [
43- 'sphinx.ext.autodoc' ,
44- 'sphinx.ext.napoleon' ,
45- ]
42+ extensions = ["sphinx.ext.autodoc" , "sphinx.ext.napoleon" ]
4643
4744# Add any paths that contain templates here, relative to this directory.
48- templates_path = [' _templates' ]
45+ templates_path = [" _templates" ]
4946
5047# The suffix of source filenames.
51- source_suffix = ' .rst'
48+ source_suffix = " .rst"
5249
5350# The encoding of source files.
5451# source_encoding = 'utf-8-sig'
5552
5653# The master toctree document.
57- master_doc = ' index'
54+ master_doc = " index"
5855
5956# General information about the project.
60- project = u' NAPALM'
61- copyright = u' 2016, David Barroso'
57+ project = u" NAPALM"
58+ copyright = u" 2016, David Barroso"
6259
6360# The version info for the project you're documenting, acts as replacement for
6461# |version| and |release|, also used in various other places throughout the
6562# built documents.
6663#
6764# The short X.Y version.
68- version = '0'
65+ version = "0"
6966# The full version, including alpha/beta/rc tags.
70- release = '1'
67+ release = "1"
7168
7269# The language for content autogenerated by Sphinx. Refer to documentation
7370# for a list of supported languages.
8178
8279# List of patterns, relative to source directory, that match files and
8380# directories to ignore when looking for source files.
84- exclude_patterns = [' _build' , ' napalm_ansible_repo' ]
81+ exclude_patterns = [" _build" , " napalm_ansible_repo" ]
8582
8683# The reST default role (used for this markup: `text`) to use for all
8784# documents.
9996# show_authors = False
10097
10198# The name of the Pygments (syntax highlighting) style to use.
102- pygments_style = ' sphinx'
99+ pygments_style = " sphinx"
103100
104101# A list of ignored prefixes for module index sorting.
105102# modindex_common_prefix = []
112109
113110# The theme to use for HTML and HTML Help pages. See the documentation for
114111# a list of builtin themes.
115- on_rtd = os .environ .get (' READTHEDOCS' , None ) == ' True'
112+ on_rtd = os .environ .get (" READTHEDOCS" , None ) == " True"
116113
117114if not on_rtd : # only import and set the theme if we're building docs locally
118115 import sphinx_rtd_theme
119- html_theme = 'sphinx_rtd_theme'
116+
117+ html_theme = "sphinx_rtd_theme"
120118 html_theme_path = [sphinx_rtd_theme .get_html_theme_path ()]
121119else :
122- html_theme = ' default'
120+ html_theme = " default"
123121
124122# Theme options are theme-specific and customize the look and feel of a theme
125123# further. For a list of options available for each theme, see the
148146# Add any paths that contain custom static files (such as style sheets) here,
149147# relative to this directory. They are copied after the builtin static files,
150148# so a file named "default.css" will overwrite the builtin "default.css".
151- html_static_path = [' _static' ]
149+ html_static_path = [" _static" ]
152150
153151# Add any extra paths that contain custom files (such as robots.txt or
154152# .htaccess) here, relative to this directory. These files are copied
197195# html_file_suffix = None
198196
199197# Output file base name for HTML help builder.
200- htmlhelp_basename = ' napalmdoc'
198+ htmlhelp_basename = " napalmdoc"
201199
202200
203201# -- Options for LaTeX output ---------------------------------------------
204202
205203latex_elements = {
206204 # The paper size ('letterpaper' or 'a4paper').
207205 # 'papersize': 'letterpaper',
208-
209206 # The font size ('10pt', '11pt' or '12pt').
210207 # 'pointsize': '10pt',
211-
212208 # Additional stuff for the LaTeX preamble.
213209 # 'preamble': '',
214210}
217213# (source start file, target name, title,
218214# author, documentclass [howto, manual, or own class]).
219215latex_documents = [
220- ('index' , 'napalm.tex' , u'NAPALM Documentation' ,
221- u'David Barroso' , 'manual' ),
216+ ("index" , "napalm.tex" , u"NAPALM Documentation" , u"David Barroso" , "manual" )
222217]
223218
224219# The name of an image file (relative to this directory) to place at the top of
246241
247242# One entry per manual page. List of tuples
248243# (source start file, name, description, authors, manual section).
249- man_pages = [
250- ('index' , 'napalm' , u'NAPALM Documentation' ,
251- [u'David Barroso' ], 1 )
252- ]
244+ man_pages = [("index" , "napalm" , u"NAPALM Documentation" , [u"David Barroso" ], 1 )]
253245
254246# If true, show URL addresses after external links.
255247# man_show_urls = False
261253# (source start file, target name, title, author,
262254# dir menu entry, description, category)
263255texinfo_documents = [
264- ('index' , 'napalm' , u'NAPALM Documentation' ,
265- u'David Barroso' , 'napalm' , 'One line description of project.' ,
266- 'Miscellaneous' ),
256+ (
257+ "index" ,
258+ "napalm" ,
259+ u"NAPALM Documentation" ,
260+ u"David Barroso" ,
261+ "napalm" ,
262+ "One line description of project." ,
263+ "Miscellaneous" ,
264+ )
267265]
268266
269267# Documents to append as an appendix to all manuals.
282280enable_pdf_build = False
283281enable_epub_build = False
284282
285- EXCLUDE_METHODS = ('cli' , 'close' , 'commit_config' , 'compare_config' ,
286- 'discard_config' , 'load_merge_candidate' ,
287- 'load_replace_candidate' , 'load_template' , 'open' ,
288- 'rollback' , 'compliance_report' , 'connection_tests' ,
289- 'post_connection_tests' , 'pre_connection_tests' )
290-
291- EXCLUDE_IN_REPORT = ('test_method_signatures' )
283+ EXCLUDE_METHODS = (
284+ "cli" ,
285+ "close" ,
286+ "commit_config" ,
287+ "compare_config" ,
288+ "discard_config" ,
289+ "load_merge_candidate" ,
290+ "load_replace_candidate" ,
291+ "load_template" ,
292+ "open" ,
293+ "rollback" ,
294+ "compliance_report" ,
295+ "connection_tests" ,
296+ "post_connection_tests" ,
297+ "pre_connection_tests" ,
298+ )
299+
300+ EXCLUDE_IN_REPORT = "test_method_signatures"
292301
293302METHOD_ALIASES = {
294- 'get_config_filtered' : 'get_config' ,
303+ "get_config_filtered" : "get_config" ,
304+ "get_arp_table_with_vrf" : "get_arp_table" ,
295305}
296306
297307
298308def _merge_results (last , intermediate ):
299- if intermediate == ' failed' :
300- return ' failed'
301- elif intermediate == ' skipped' :
302- return ' failed' if last == ' failed' else ' skipped'
303- elif intermediate == ' passed' :
304- return 'ok' if last == 'ok' else last
309+ if intermediate == " failed" :
310+ return " failed"
311+ elif intermediate == " skipped" :
312+ return " failed" if last == " failed" else " skipped"
313+ elif intermediate == " passed" :
314+ return "ok" if last == "ok" else last
305315 else :
306316 return last
307317
@@ -310,23 +320,25 @@ def build_napalm_ansible_module_docs(app):
310320 """Create documentation for Ansible modules."""
311321
312322 # Add script to clone napalm-ansible repo
313- status = subprocess .call ("./build-ansible-module-docs.sh" , stdout = sys .stdout , stderr = sys .stderr )
323+ status = subprocess .call (
324+ "./build-ansible-module-docs.sh" , stdout = sys .stdout , stderr = sys .stderr
325+ )
314326
315327 if status != 0 :
316328 print ("Something bad happened when processing the Ansible modules." )
317329 sys .exit (- 1 )
318330
319331 env = Environment (loader = FileSystemLoader ("." ))
320332
321- modules_dir = ' ./integrations/ansible/modules/source'
322- module_files = glob (' {0}/*.json' .format (modules_dir ))
333+ modules_dir = " ./integrations/ansible/modules/source"
334+ module_files = glob (" {0}/*.json" .format (modules_dir ))
323335 for module_file in module_files :
324- with open (module_file , 'r' ) as f :
325- module = module_file .split ('/' )[- 1 ].split ('.' )[0 ]
336+ with open (module_file , "r" ) as f :
337+ module = module_file .split ("/" )[- 1 ].split ("." )[0 ]
326338 data = json .loads (f .read ())
327- data [' name' ] = module
339+ data [" name" ] = module
328340
329- module_dir = ' ./integrations/ansible/modules/{0}' .format (module )
341+ module_dir = " ./integrations/ansible/modules/{0}" .format (module )
330342
331343 try :
332344 os .stat (module_dir )
@@ -336,7 +348,7 @@ def build_napalm_ansible_module_docs(app):
336348 template_file = env .get_template ("ansible-module.j2" )
337349 rendered_template = template_file .render (** data )
338350
339- with open (' {0}/index.rst' .format (module_dir ), 'w' ) as f :
351+ with open (" {0}/index.rst" .format (module_dir ), "w" ) as f :
340352 f .write (rendered_template )
341353
342354
@@ -349,26 +361,28 @@ def build_getters_support_matrix(app):
349361 sys .exit (- 1 )
350362
351363 drivers = set ()
352- matrix = {m : defaultdict (dict ) for m in dir (NetworkDriver )
353- if not (m .startswith ('_' ) or
354- m in EXCLUDE_METHODS )}
364+ matrix = {
365+ m : defaultdict (dict )
366+ for m in dir (NetworkDriver )
367+ if not (m .startswith ("_" ) or m in EXCLUDE_METHODS )
368+ }
355369
356370 regex_name = re .compile (r"(?P<driver>\w+)\/.*::test_(?P<getter>\w+)" )
357371
358- filename = ' ./support/tests/report.json'
359- with open (filename , 'r' ) as f :
372+ filename = " ./support/tests/report.json"
373+ with open (filename , "r" ) as f :
360374 data = json .loads (f .read ())
361375 for test in data ["report" ]["tests" ]:
362- match = regex_name .search (test [' name' ])
376+ match = regex_name .search (test [" name" ])
363377 if match :
364- driver = match .group (' driver' )
378+ driver = match .group (" driver" )
365379 drivers .add (driver )
366- method = match .group (' getter' )
380+ method = match .group (" getter" )
367381 else :
368382 continue
369383 if method in EXCLUDE_IN_REPORT :
370384 continue
371- result = test [' outcome' ]
385+ result = test [" outcome" ]
372386
373387 if method in METHOD_ALIASES .keys ():
374388 method = METHOD_ALIASES [method ]
@@ -380,17 +394,18 @@ def build_getters_support_matrix(app):
380394 drivers = sorted (drivers )
381395 env = Environment (loader = FileSystemLoader ("." ))
382396 template_file = env .get_template ("matrix.j2" )
383- rendered_template = template_file .render (matrix = matrix , drivers = drivers ,
384- sorted_methods = sorted_methods )
397+ rendered_template = template_file .render (
398+ matrix = matrix , drivers = drivers , sorted_methods = sorted_methods
399+ )
385400
386- with open (' support/matrix.rst' , 'w' ) as f :
401+ with open (" support/matrix.rst" , "w" ) as f :
387402 f .write (rendered_template )
388403
389404
390405def setup (app ):
391406 """Map methods to states of the documentation build."""
392- app .connect (' builder-inited' , build_getters_support_matrix )
393- app .connect (' builder-inited' , build_napalm_ansible_module_docs )
407+ app .connect (" builder-inited" , build_getters_support_matrix )
408+ app .connect (" builder-inited" , build_napalm_ansible_module_docs )
394409
395410
396411build_getters_support_matrix (None )
0 commit comments