|
18 | 18 | sys.path.insert(0, os.path.abspath('..'))
|
19 | 19 | print(os.path.abspath('..'))
|
20 | 20 |
|
21 |
| - |
22 | 21 | # -- Project information -----------------------------------------------------
|
23 | 22 |
|
24 | 23 | project = 'Cloudant Python SDK'
|
25 |
| -copyright = 'Copyright IBM Corp. 2021' |
| 24 | +copyright = 'Copyright IBM Corp. 2021, 2023.' |
26 | 25 | author = '@IBM/cloudant-sdks'
|
27 | 26 |
|
28 | 27 | # -- General configuration ---------------------------------------------------
|
|
31 | 30 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
32 | 31 | # ones.
|
33 | 32 | extensions = [
|
34 |
| - 'sphinx.ext.autodoc' |
| 33 | + 'autodoc2', |
| 34 | + 'myst_parser', |
| 35 | + 'sphinx_rtd_theme', |
| 36 | +] |
| 37 | + |
| 38 | +myst_enable_extensions = ['colon_fence', 'fieldlist'] |
| 39 | + |
| 40 | +autodoc2_packages = [ |
| 41 | + { |
| 42 | + 'path': '../ibmcloudant', |
| 43 | + 'exclude_files': [ |
| 44 | + 'common.py', |
| 45 | + 'version.py', |
| 46 | + 'cloudant_base_service.py', |
| 47 | + 'couchdb_session_get_authenticator_patch.py', |
| 48 | + 'couchdb_session_token_manager.py' |
| 49 | + ] |
| 50 | + } |
| 51 | +] |
| 52 | + |
| 53 | +autodoc2_sort_names = True |
| 54 | + |
| 55 | +autodoc2_index_template = None |
| 56 | + |
| 57 | +autodoc2_hidden_objects = ['dunder', 'private', 'inherited'] |
| 58 | + |
| 59 | +autodoc2_docstring_parser_regexes = [ |
| 60 | + (r'.*', 'myst'), |
35 | 61 | ]
|
36 | 62 |
|
37 | 63 | # Add any paths that contain templates here, relative to this directory.
|
|
40 | 66 | # List of patterns, relative to source directory, that match files and
|
41 | 67 | # directories to ignore when looking for source files.
|
42 | 68 | # This pattern also affects html_static_path and html_extra_path.
|
43 |
| -exclude_patterns = [] |
| 69 | +exclude_patterns = ['apidocs/ibmcloudant/ibmcloudant.rst'] |
| 70 | + |
| 71 | +# -- Patch generated rst ----------------------------------------------------- |
44 | 72 |
|
| 73 | +file_path = '../ibmcloudant/cloudant_v1.py' |
| 74 | +print(f'[patching] file {file_path}') |
| 75 | +# read source file |
| 76 | +with open(file_path, 'r') as file: |
| 77 | + lines = file.readlines() |
| 78 | +# patch broken markup |
| 79 | +codeblock = False |
| 80 | +for i in range(len(lines)): |
| 81 | + # replace class vars to :param: for better rendering |
| 82 | + if ':attr ' in lines[i]: |
| 83 | + lines[i] = lines[i].replace(':attr', ':param') |
| 84 | + # replace note with tip admonition |
| 85 | + if '### Note' in lines[i]: |
| 86 | + lines[i] = ' :::{tip}\n' |
| 87 | + codeblock = True |
| 88 | + if codeblock and lines[i] == '\n': |
| 89 | + lines[i] = ' :::\n\n' |
| 90 | + codeblock = False |
| 91 | +# write back |
| 92 | +with open(file_path, 'w') as file: |
| 93 | + file.writelines(lines) |
45 | 94 |
|
46 | 95 | # -- Options for HTML output -------------------------------------------------
|
47 | 96 |
|
48 | 97 | # The theme to use for HTML and HTML Help pages. See the documentation for
|
49 | 98 | # a list of builtin themes.
|
50 | 99 | #
|
51 |
| -html_theme = 'alabaster' |
| 100 | +html_theme = 'sphinx_rtd_theme' |
| 101 | +html_theme_options = { |
| 102 | + 'collapse_navigation': False |
| 103 | +} |
52 | 104 |
|
53 | 105 | # Add any paths that contain custom static files (such as style sheets) here,
|
54 | 106 | # relative to this directory. They are copied after the builtin static files,
|
|
0 commit comments