blob: ce1d48d8ede5b16f84cb401ce7354fa6c19eab67 [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
25# -- yaml2rst ----------------------------------------------------------------
26import os
27import glob
28import yaml2rst
29from yaml4rst.reformatter import YamlRstReformatter
30import pathlib
31
32for defaults_file in glob.glob("../../roles/*/defaults/main.yml"):
33 role_name = defaults_file.split("/")[-3]
34
35 YamlRstReformatter._HEADER_END_LINES = {
36 'yaml4rst': [
37 '# Default variables',
38 '# :local:',
39 '# .. contents:: Sections',
40 '# .. include:: includes/all.rst',
41 '# .. include:: includes/role.rst',
42 '# .. include:: ../../../includes/global.rst',
43 '# -----------------',
44 ],
45 }
46
47 reformatter = YamlRstReformatter(
48 preset='yaml4rst',
49 template_path=os.path.join(
50 os.path.abspath(os.path.dirname(__file__)),
51 '_templates',
52 ),
53 config={
54 'ansible_full_role_name': f"vexxhost.atmosphere.{role_name}",
55 'ansible_role_name': role_name,
56 }
57 )
58 reformatter.read_file(defaults_file)
59 reformatter.reformat()
60 reformatter.write_file(
61 output_file=defaults_file,
62 only_if_changed=True,
63 )
64
65 pathlib.Path(f"roles/{role_name}/defaults").mkdir(parents=True, exist_ok=True)
66
67 rst_content = yaml2rst.convert_file(
68 defaults_file,
69 f"roles/{role_name}/defaults/main.rst",
70 strip_regex=r'\s*(:?\[{3}|\]{3})\d?$',
71 yaml_strip_regex=r'^\s{66,67}#\s\]{3}\d?$',
72 )
73
74
75# -- Project information -----------------------------------------------------
76
77project = 'Atmosphere'
78copyright = '2022, VEXXHOST, Inc.'
79author = 'VEXXHOST, Inc.'
80
81
82# -- General configuration ---------------------------------------------------
83
84# Add any Sphinx extension module names here, as strings. They can be
85# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
86# ones.
87extensions = [
88 'reno.sphinxext',
89]
90
91# Add any paths that contain templates here, relative to this directory.
92templates_path = ['_templates']
93
94# List of patterns, relative to source directory, that match files and
95# directories to ignore when looking for source files.
96# This pattern also affects html_static_path and html_extra_path.
97exclude_patterns = []
98
99
100# -- Options for HTML output -------------------------------------------------
101
102# The theme to use for HTML and HTML Help pages. See the documentation for
103# a list of builtin themes.
104#
105html_theme = 'sphinx_rtd_theme'
106
107# Add any paths that contain custom static files (such as style sheets) here,
108# relative to this directory. They are copied after the builtin static files,
109# so a file named "default.css" will overwrite the builtin "default.css".
110html_static_path = ['_static']