]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
doc/conf: generate releases.json in conf.py 38203/head
authorKefu Chai <kchai@redhat.com>
Fri, 20 Nov 2020 04:55:38 +0000 (12:55 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 20 Nov 2020 04:59:22 +0000 (12:59 +0800)
pave the road to build all the ingredients of the document using RTD
facility.

Signed-off-by: Kefu Chai <kchai@redhat.com>
admin/build-doc
doc/conf.py

index ac655b75e05c58605b2d880943ec124fa5b20023..1aba2b5662d248eee6fbbdfe29509783200c75ea 100755 (executable)
@@ -139,24 +139,6 @@ for target in $sphinx_targets; do
 
 done
 
-# build the releases.json. this reads in the yaml version and dumps
-# out the json representation of the same file. the resulting releases.json
-# should be served from the root of hosted site.
-$vdir/bin/python << EOF > $TOPDIR/build-doc/output/html/_static/releases.json
-from __future__ import print_function
-import datetime
-import json
-import yaml
-
-def json_serialize(obj):
-    if isinstance(obj, datetime.date):
-        return obj.isoformat()
-
-with open("$TOPDIR/doc/releases/releases.yml", 'r') as fp:
-    releases = yaml.safe_load(fp)
-    print(json.dumps(releases, indent=2, default=json_serialize))
-EOF
-
 #
 # Build and install JavaDocs
 #
index 31ea852a3422d1bf10342e47e7681abb8b00387a..af6e5cb431086a910724a434c1c082db179eecc6 100644 (file)
@@ -1,7 +1,11 @@
+import datetime
 import fileinput
+import json
+import os
 import shutil
 import sys
-import os
+
+import yaml
 
 # project information
 project = 'Ceph'
@@ -197,6 +201,27 @@ for c in pybinds:
         sys.path.insert(0, pybind)
 
 
+# build the releases.json. this reads in the yaml version and dumps
+# out the json representation of the same file. the resulting releases.json
+# should be served from '/_static/releases.json' of hosted site.
+def yaml_to_json(input_path, output_path):
+    def json_serialize(obj):
+        if isinstance(obj, datetime.date):
+            return obj.isoformat()
+
+    yaml_fn = os.path.join(top_level, input_path)
+    json_fn = os.path.join(top_level, output_path)
+
+    def process(app):
+        with open(yaml_fn) as input:
+            with open(json_fn, 'w') as output:
+                releases = yaml.safe_load(input)
+                s = json.dumps(releases, indent=2, default=json_serialize)
+                output.write(s)
+
+    return process
+
+
 # handles edit-on-github and old version warning display
 def setup(app):
     app.add_js_file('js/ceph.js')
@@ -208,3 +233,6 @@ def setup(app):
                 generate_state_diagram(['src/osd/PeeringState.h',
                                         'src/osd/PeeringState.cc'],
                                        'doc/dev/peering_graph.generated.dot'))
+    app.connect('builder-inited',
+                yaml_to_json('doc/releases/releases.yml',
+                             'doc/_static/releases.json'))