summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorMike Dirolf <mike@10gen.com>2010-07-14 13:36:29 -0400
committerMike Dirolf <mike@10gen.com>2010-07-14 13:36:29 -0400
commit19f4563195e5401e25ec419ade214bcea0ad2148 (patch)
tree058495eca465fa6586e2e08be5350315ec55842e /buildscripts
parent9c035c362767e448fd9c501c9a1930589841231a (diff)
downloadmongo-19f4563195e5401e25ec419ade214bcea0ad2148.tar.gz
update docs.py to build C++ client docs too
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/docs.py75
1 files changed, 55 insertions, 20 deletions
diff --git a/buildscripts/docs.py b/buildscripts/docs.py
index b4e213c81d7..10bf5af55e9 100644
--- a/buildscripts/docs.py
+++ b/buildscripts/docs.py
@@ -1,33 +1,68 @@
+"""Build the C++ client docs and the MongoDB server docs.
+"""
+from __future__ import with_statement
import os
+import shutil
+import subprocess
+
import markdown
-def convertDir( source , dest ):
-
- if not os.path.exists( dest ):
- os.mkdir( dest )
- for x in os.listdir( source + "/" ):
- if not x.endswith( ".md" ):
+def clean_dir(dir):
+ try:
+ shutil.rmtree(dir)
+ except:
+ pass
+ os.makedirs(dir)
+
+
+def convert_dir(source, dest):
+ clean_dir(dest)
+
+ for x in os.listdir(source + "/"):
+ if not x.endswith(".md"):
continue
- f = open( source + "/" + x , 'r' )
- raw = f.read()
- f.close()
+ with open("%s/%s" % (source, x)) as f:
+ raw = f.read()
+
+ html = markdown.markdown(raw)
+ print(x)
+
+ with open("%s/%s" % (dest, x.replace(".md", ".html")), 'w') as o:
+ o.write(html)
+
- html = markdown.markdown( raw )
- print( x )
-
- o = open( dest + "/" + x.replace( ".md" , ".html" ) , 'w' )
- o.write( html )
- o.close()
-
+def gen_cplusplus(dir):
+ clean_dir(dir)
+ clean_dir("docs/doxygen")
+ # Too noisy...
+ with open("/dev/null") as null:
+ subprocess.call(["doxygen", "doxygenConfig"], stdout=null, stderr=null)
+
+ os.rename("docs/doxygen/html", dir)
+
+
+def version():
+ """Get the server version from doxygenConfig.
+ """
+ with open("doxygenConfig") as f:
+ for line in f.readlines():
+ if line.startswith("PROJECT_NUMBER"):
+ return line.split("=")[1].strip()
+
+
+def main():
+ v = version()
+ print("Generating server docs in docs/html/internal/%s" % v)
+ convert_dir("docs", "docs/html/internal/%s" % v)
+ print("Generating C++ docs in docs/html/cplusplus/%s" % v)
+ gen_cplusplus("docs/html/cplusplus/%s" % v)
-def convertMain():
- convertDir( "docs" , "docs/html" )
if __name__ == "__main__":
- convertMain()
+ main()
+
-