blob: d846a1b11fbdc3b5fe2ff270f4b1cf1abc1f29ca [file] [log] [blame]
Mohammed Naserab033e12022-03-13 21:07:28 -04001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15# -- Path setup --------------------------------------------------------------
16
17# If extensions (or modules to document with autodoc) are in another directory,
18# add these directories to sys.path here. If the directory is relative to the
19# documentation root, use os.path.abspath to make it absolute, like shown here.
20#
21# import os
22# import sys
23# sys.path.insert(0, os.path.abspath('.'))
24
Mohammed Naserf3a14a32022-09-19 15:15:39 -040025import glob
26
Mohammed Naserab033e12022-03-13 21:07:28 -040027# -- yaml2rst ----------------------------------------------------------------
28import os
Mohammed Naserf3a14a32022-09-19 15:15:39 -040029import pathlib
30
Mohammed Naserab033e12022-03-13 21:07:28 -040031import yaml2rst
32from yaml4rst.reformatter import YamlRstReformatter
Mohammed Naserab033e12022-03-13 21:07:28 -040033
34for defaults_file in glob.glob("../../roles/*/defaults/main.yml"):
35 role_name = defaults_file.split("/")[-3]
36
37 YamlRstReformatter._HEADER_END_LINES = {
Mohammed Naserf3a14a32022-09-19 15:15:39 -040038 "yaml4rst": [
39 "# Default variables",
40 "# :local:",
41 "# .. contents:: Sections",
42 "# .. include:: includes/all.rst",
43 "# .. include:: includes/role.rst",
44 "# .. include:: ../../../includes/global.rst",
45 "# -----------------",
Mohammed Naserab033e12022-03-13 21:07:28 -040046 ],
47 }
48
49 reformatter = YamlRstReformatter(
Mohammed Naserf3a14a32022-09-19 15:15:39 -040050 preset="yaml4rst",
Mohammed Naserab033e12022-03-13 21:07:28 -040051 template_path=os.path.join(
52 os.path.abspath(os.path.dirname(__file__)),
Mohammed Naserf3a14a32022-09-19 15:15:39 -040053 "_templates",
Mohammed Naserab033e12022-03-13 21:07:28 -040054 ),
55 config={
Mohammed Naserf3a14a32022-09-19 15:15:39 -040056 "ansible_full_role_name": f"vexxhost.atmosphere.{role_name}",
57 "ansible_role_name": role_name,
58 },
Mohammed Naserab033e12022-03-13 21:07:28 -040059 )
60 reformatter.read_file(defaults_file)
61 reformatter.reformat()
62 reformatter.write_file(
63 output_file=defaults_file,
64 only_if_changed=True,
65 )
66
67 pathlib.Path(f"roles/{role_name}/defaults").mkdir(parents=True, exist_ok=True)
68
69 rst_content = yaml2rst.convert_file(
70 defaults_file,
71 f"roles/{role_name}/defaults/main.rst",
Mohammed Naserf3a14a32022-09-19 15:15:39 -040072 strip_regex=r"\s*(:?\[{3}|\]{3})\d?$",
73 yaml_strip_regex=r"^\s{66,67}#\s\]{3}\d?$",
Mohammed Naserab033e12022-03-13 21:07:28 -040074 )
75
76
77# -- Project information -----------------------------------------------------
78
Mohammed Naserf3a14a32022-09-19 15:15:39 -040079project = "Atmosphere"
80copyright = "2022, VEXXHOST, Inc."
81author = "VEXXHOST, Inc."
Mohammed Naserab033e12022-03-13 21:07:28 -040082
83
84# -- General configuration ---------------------------------------------------
85
86# Add any Sphinx extension module names here, as strings. They can be
87# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
88# ones.
89extensions = [
Mohammed Naserf3a14a32022-09-19 15:15:39 -040090 "reno.sphinxext",
Mohammed Naserab033e12022-03-13 21:07:28 -040091]
92
93# Add any paths that contain templates here, relative to this directory.
Mohammed Naserf3a14a32022-09-19 15:15:39 -040094templates_path = ["_templates"]
Mohammed Naserab033e12022-03-13 21:07:28 -040095
96# List of patterns, relative to source directory, that match files and
97# directories to ignore when looking for source files.
98# This pattern also affects html_static_path and html_extra_path.
99exclude_patterns = []
100
101
102# -- Options for HTML output -------------------------------------------------
103
104# The theme to use for HTML and HTML Help pages. See the documentation for
105# a list of builtin themes.
106#
Mohammed Naserf3a14a32022-09-19 15:15:39 -0400107html_theme = "sphinx_rtd_theme"
Mohammed Naserab033e12022-03-13 21:07:28 -0400108
109# Add any paths that contain custom static files (such as style sheets) here,
110# relative to this directory. They are copied after the builtin static files,
111# so a file named "default.css" will overwrite the builtin "default.css".
Mohammed Naserf3a14a32022-09-19 15:15:39 -0400112html_static_path = ["_static"]