Debian Codegraph @

doc/source/conf.py

raw
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 #
4 # KIWI NG documentation build configuration file
5 #
6 from datetime import datetime
7 import sys
8 from os.path import abspath, dirname, join, normpath
9 import shlex
10
11 from sphinx.transforms import SphinxTransform
12
13
14 # If extensions (or modules to document with autodoc) are in another directory,
15 # add these directories to sys.path here. If the directory is relative to the
16 # documentation root, use os.path.abspath to make it absolute, like shown here.
17 _path = normpath(join(dirname(__file__), "../.."))
18 sys.path.insert(0, _path)
19
20
21 # -- General configuration ------------------------------------------------
22
23 # If your documentation needs a minimal Sphinx version, state it here.
24 #needs_sphinx = '1.0'
25
26 # Add any Sphinx extension module names here, as strings. They can be
27 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
28 # ones.
29
30 extensions = [
31 'sphinx.ext.autodoc',
32 'sphinx.ext.autosummary',
33 'sphinx.ext.extlinks',
34 'sphinx.ext.todo',
35 'sphinx.ext.ifconfig',
36 'sphinx.ext.viewcode',
37 'sphinx.ext.autodoc',
38 'sphinx_rtd_theme'
39 ]
40
41 docopt_ignore = [
42 'kiwi.cli',
43 'kiwi.tasks.system_build',
44 'kiwi.tasks.system_prepare',
45 'kiwi.tasks.system_update',
46 'kiwi.tasks.system_create',
47 'kiwi.tasks.result_list',
48 'kiwi.tasks.result_bundle',
49 'kiwi.tasks.image_resize',
50 'kiwi.tasks.image_info'
51 ]
52
53 def remove_module_docstring(app, what, name, obj, options, lines):
54 if what == "module" and name in docopt_ignore:
55 del lines[:]
56
57 def prologReplace(app, docname, source):
58 result = source[0]
59 for key in app.config.prolog_replacements:
60 result = result.replace(key, app.config.prolog_replacements[key])
61 source[0] = result
62
63 class AddRootRole(SphinxTransform):
64 # Runs after the document is parsed and the source path is set
65 default_priority = 500
66
67 def apply(self):
68 master_doc = self.config.master_doc
69
70 # Get the current document name relative to the source directory
71 # e.g., 'index', 'folder/subpage', etc.
72 docname = self.env.docname
73
74 # Only apply the attribute if this is the main entry point
75 if docname == master_doc:
76 self.document['role'] = 'main'
77
78
79 def setup(app):
80 app.add_config_value('prolog_replacements', {}, True)
81 app.add_transform(AddRootRole)
82 app.connect('source-read', prologReplace)
83 app.connect("autodoc-process-docstring", remove_module_docstring)
84
85
86 prolog_replacements = {
87 '{exc_image_base_name}': 'kiwi-test-image-some',
88 '{exc_image_base_name_pxe}': 'kiwi-test-image-pxe',
89 '{exc_image_base_name_kis}': 'kiwi-test-image-kis',
90 '{exc_image_base_name_vagrant}': 'kiwi-test-image-vagrant',
91 '{exc_image_base_name_disk}': 'kiwi-test-image-disk',
92 '{exc_image_base_name_disk_simple}': 'kiwi-test-image-disk-simple',
93 '{exc_image_base_name_live}': 'kiwi-test-image-live',
94 '{exc_image_base_name_docker}': 'kiwi-test-image-docker',
95 '{exc_image_base_name_enclave}': 'kiwi-test-image-nitro-enclave',
96 '{exc_netboot}': 'netboot/suse-tumbleweed',
97 '{exc_description_pxe}': 'x86/tumbleweed/test-image-pxe',
98 '{exc_description_kis}': 'x86/tumbleweed/test-image-kis',
99 '{exc_description_vagrant}': 'x86/leap/test-image-vagrant',
100 '{exc_description_disk}': 'x86/leap/test-image-disk',
101 '{exc_description_disk_simple}': 'x86/leap/test-image-disk-simple',
102 '{exc_description_live}': 'x86/leap/test-image-live',
103 '{exc_description_wsl}': 'x86/tumbleweed/test-image-wsl',
104 '{exc_description_docker}': 'x86/leap/test-image-docker',
105 '{exc_description_enclave}': 'x86/rawhide/test-image-nitro-enclave',
106 '{exc_os_version}': '16.0',
107 '{exc_image_version}': '1.15.6',
108 '{exc_repo_leap}': 'https://download.opensuse.org/distribution/leap/16.0/repo/oss',
109 '{exc_repo_tumbleweed}': 'https://download.opensuse.org/tumbleweed/repo/oss',
110 '{exc_repo_rawhide}': 'https://mirrors.fedoraproject.org/metalink?repo=rawhide&arch=x86_64',
111 '{exc_kiwi_repo}':
112 'obs://Virtualization:Appliances:Builder/openSUSE_Leap_16.0',
113 '{exc_repo_obs}': 'obs://openSUSE:Leap:16.0/standard',
114 '{schema_version}': '8.5',
115 '{kiwi}': 'KIWI NG',
116 '{kiwi-product}': 'KIWI Next Generation (KIWI NG)',
117 '{kiwi-legacy}': 'KIWI Legacy'
118 }
119
120 latex_documents = [
121 ('index', 'kiwi.tex', 'KIWI NG Documentation', 'Marcus Schäfer', 'manual')
122 ]
123 latex_elements = {
124 'papersize': 'a4paper',
125 'pointsize':'12pt',
126 'classoptions': ',openany',
127 'babel': '\\usepackage[english]{babel}',
128 'preamble': r'''
129 \makeatletter
130 \fancypagestyle{normal}{
131 \fancyhf{}
132 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
133 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
134 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
135 \fancyhead[LE,RO]{{\py@HeaderFamily \@title, \py@release}}
136 \renewcommand{\headrulewidth}{0.4pt}
137 \renewcommand{\footrulewidth}{0.4pt}
138 }
139 \makeatother
140 '''
141 }
142
143 # Add any paths that contain templates here, relative to this directory.
144 templates_path = ['.templates']
145
146 # The suffix(es) of source filenames.
147 # You can specify multiple suffix as a list of string:
148 # source_suffix = ['.rst', '.md']
149 source_suffix = '.rst'
150
151 # The encoding of source files.
152 source_encoding = 'utf-8-sig'
153
154 # The master toctree document.
155 master_doc = 'index'
156
157 default_role="py:obj"
158
159 # General information about the project.
160 project = 'KIWI NG'
161 author = 'Marcus Schäfer'
162 copyright = f'2020-{datetime.now().year}, {author}'
163
164 # The version info for the project you're documenting, acts as replacement for
165 # |version| and |release|, also used in various other places throughout the
166 # built documents.
167 #
168 # The short X.Y version.
169 version = '10.3.11'
170 # The full version, including alpha/beta/rc tags.
171 release = version
172
173 # The language for content autogenerated by Sphinx. Refer to documentation
174 # for a list of supported languages.
175 #
176 # This is also used if you do content translation via gettext catalogs.
177 # Usually you set "language" from the command line for these cases.
178 language = 'en'
179
180 # List of patterns, relative to source directory, that match files and
181 # directories to ignore when looking for source files.
182 exclude_patterns = []
183
184 # If true, '()' will be appended to :func: etc. cross-reference text.
185 #add_function_parentheses = True
186
187 # If true, the current module name will be prepended to all description
188 # unit titles (such as .. function::).
189 #add_module_names = True
190
191 # If true, sectionauthor and moduleauthor directives will be shown in the
192 # output. They are ignored by default.
193 #show_authors = False
194
195 # The name of the Pygments (syntax highlighting) style to use.
196 pygments_style = 'sphinx'
197
198 # A list of ignored prefixes for module index sorting.
199 #modindex_common_prefix = []
200
201 # If true, keep warnings as "system message" paragraphs in the built documents.
202 #keep_warnings = False
203
204 # If true, `todo` and `todoList` produce output, else they produce nothing.
205 todo_include_todos = True
206
207 autosummary_generate = True
208
209 # -- Options for HTML output ----------------------------------------------
210
211 #html_short_title = '%s-%s' % (project, version)
212 #html_last_updated_fmt = '%b %d, %Y'
213 #html_split_index = True
214 html_logo = '.images/kiwi-logo.png'
215
216 html_sidebars = {
217 '**': [
218 'localtoc.html', 'relations.html',
219 'about.html', 'searchbox.html',
220 ]
221 }
222
223 html_theme = "sphinx_rtd_theme"
224
225 html_theme_options = {
226 'collapse_navigation': False,
227 'sticky_navigation': True,
228 'navigation_depth': 4,
229 'includehidden': True,
230 'titles_only': False
231 }
232
233 # -- Options for manual page output ---------------------------------------
234
235 # The man page toctree documents.
236 kiwi_doc = 'commands/kiwi'
237 result_list_doc = 'commands/result_list'
238 result_bundle_doc = 'commands/result_bundle'
239 system_prepare_doc = 'commands/system_prepare'
240 system_update_doc = 'commands/system_update'
241 system_build_doc = 'commands/system_build'
242 system_create_doc = 'commands/system_create'
243 image_resize_doc = 'commands/image_resize'
244 image_info_doc = 'commands/image_info'
245
246 # One entry per manual page. List of tuples
247 # (source start file, name, description, authors, manual section).
248 man_pages = [
249 (
250 kiwi_doc,
251 'kiwi', 'Creating Operating System Images',
252 [author],
253 8
254 ),
255 (
256 result_list_doc,
257 'kiwi::result::list',
258 'List build results',
259 [author],
260 8
261 ),
262 (
263 result_bundle_doc,
264 'kiwi::result::bundle',
265 'Bundle build results',
266 [author],
267 8
268 ),
269 (
270 system_prepare_doc,
271 'kiwi::system::prepare',
272 'Prepare image root system',
273 [author],
274 8
275 ),
276 (
277 system_create_doc,
278 'kiwi::system::create',
279 'Create image from prepared root system',
280 [author],
281 8
282 ),
283 (
284 system_update_doc,
285 'kiwi::system::update',
286 'Update/Upgrade image root system',
287 [author],
288 8
289 ),
290 (
291 system_build_doc,
292 'kiwi::system::build',
293 'Build image in combined prepare and create step',
294 [author],
295 8
296 ),
297 (
298 image_resize_doc,
299 'kiwi::image::resize',
300 'Resize disk images to new geometry',
301 [author],
302 8
303 ),
304 (
305 image_info_doc,
306 'kiwi::image::info',
307 'Provide detailed information about an image description',
308 [author],
309 8
310 )
311 ]
312
313 # If true, show URL addresses after external links.
314 #man_show_urls = False