File: docs.py

package info (click to toggle)
mongo-cxx-driver-legacy 1.1.3-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 9,860 kB
  • sloc: cpp: 93,675; sh: 11,310; python: 5,340; ansic: 938; makefile: 340; perl: 213
file content (58 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Build the C++ client docs.
"""

from __future__ import with_statement

import os
import shutil
import subprocess

def clean_dir(dir):
    try:
        shutil.rmtree(dir)
    except:
        pass
    os.makedirs(dir)

def gen_cplusplus(dir):
    clean_dir(dir)
    clean_dir("docs/doxygen")

    # Too noisy...
    with open("/dev/null") as null:
        subprocess.call(["doxygen", "etc/doxygen/config"], stdout=null, stderr=null)

    os.rename("docs/doxygen/html", dir)

def version():
    """Get the server version from doxygenConfig.
    """
    with open("etc/doxygen/config") as f:
        for line in f.readlines():
            if line.startswith("PROJECT_NUMBER"):
                return line.split("=")[1].strip()

def link_current(version):
    """Create current link to the most recently generated documentation
    """
    print("Updating 'current' docs symlink")

    link_path = 'docs/html/cplusplus/current'

    try:
        os.unlink(link_path)
    except OSError:
        pass

    os.symlink(version, link_path)

def main():
    v = version()
    print("Generating C++ docs in docs/html/cplusplus/%s" % v)
    gen_cplusplus("docs/html/cplusplus/%s" % v)
    link_current(v)

if __name__ == "__main__":
    main()