]> git.proxmox.com Git - mirror_frr.git/commitdiff
doc: test sphinx version, use correct apis
authorMark Stapp <mjs@voltanet.io>
Wed, 26 Aug 2020 14:45:21 +0000 (10:45 -0400)
committerMark Stapp <mjs@voltanet.io>
Wed, 26 Aug 2020 16:17:42 +0000 (12:17 -0400)
Some Sphinx apis have changed over time; test the installed
version and use the apis that match the version.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
doc/user/conf.py

index d8a188b1529442f86e04c467c6d3a2655c563641..1f6f050bcf67afb2622bb8494678fe31337eace3 100644 (file)
@@ -16,6 +16,7 @@ import sys
 import os
 import re
 import pygments
+import sphinx
 from sphinx.highlighting import lexers
 
 # If extensions (or modules to document with autodoc) are in another directory,
@@ -359,14 +360,36 @@ texinfo_documents = [
 with open('../extra/frrlexer.py', 'rb') as lex:
     frrlexerpy = lex.read()
 
+# Parse version string into int array
+def vparse(s):
+    a = []
+
+    for c in s:
+        if c != '.':
+            a.append(int(c))
+
+    while len(a) < 3:
+        a.append(0)
+
+    return a[:3]
+
 # custom extensions here
 def setup(app):
     # object type for FRR CLI commands, can be extended to document parent CLI
     # node later on
     app.add_object_type('clicmd', 'clicmd')
+
     # css overrides for HTML theme
-    app.add_stylesheet('overrides.css')
-    app.add_javascript('overrides.js')
+    # Note sphinx version differences
+    sver = vparse(sphinx.__version__)
+
+    if sver < vparse('1.8.0') :
+        app.add_stylesheet('overrides.css')
+        app.add_javascript('overrides.js')
+    else:
+        app.add_css_file('overrides.css')
+        app.add_js_file('overrides.js')
+
     # load Pygments lexer for FRR config syntax
     #
     # NB: in Pygments 2.2+ this can be done with `load_lexer_from_file`, but we