-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Autogenerate db/config.cc docs
Update layout docs: remove output param docs: generate cc properties on build docs: track cc file on change rm: note dependency docs: clean _data Fixes #8424. Closes #14973
- Loading branch information
1 parent
1aa01d6
commit e23d9cd
Showing
7 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
import re | ||
import yaml | ||
from sphinx.application import Sphinx | ||
|
||
CONFIG_FILE_PATH = '../db/config.cc' | ||
DESTINATION_PATH = '_data/db_config.yaml' | ||
|
||
def create_yaml_file(destination, data): | ||
current_data = None | ||
|
||
try: | ||
with open(destination, 'r') as file: | ||
current_data = yaml.safe_load(file) | ||
except FileNotFoundError: | ||
pass | ||
|
||
if current_data != data: | ||
os.makedirs(os.path.dirname(destination), exist_ok=True) | ||
with open(destination, 'w') as file: | ||
yaml.dump(data, file) | ||
|
||
def parse_db_properties(config_file): | ||
with open(config_file, 'r') as file: | ||
content = file.read() | ||
|
||
pattern = r',\s*(\w+)\(this,\s*"(\w+)",\s*(?:liveness::(\w+),\s*)?value_status::(\w+),\s*([^,]+),\s*"([^"]+)"\)' | ||
matches = re.findall(pattern, content) | ||
|
||
properties = [] | ||
for match in matches: | ||
property_data = { | ||
"name": match[1].strip(), | ||
"value_status": match[3].strip(), | ||
"default": match[4].strip(), | ||
"liveness": 'True' if match[2] else 'False', | ||
"description": match[5].strip().replace('\n', '<br />') | ||
} | ||
properties.append(property_data) | ||
|
||
return properties | ||
|
||
def generate_cc_docs(app: Sphinx): | ||
dest_path = os.path.join(app.builder.srcdir, DESTINATION_PATH) | ||
parsed_properties = parse_db_properties(CONFIG_FILE_PATH) | ||
create_yaml_file(dest_path, parsed_properties) | ||
|
||
|
||
def setup(app: Sphinx): | ||
app.connect("builder-inited", generate_cc_docs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. -*- mode: rst -*- | ||
.. list-table:: | ||
:widths: 20 80 | ||
:header-rows: 1 | ||
|
||
* - Name | ||
- Description | ||
{% for item in data %} | ||
|
||
* - .. _config_{{ item.name }}: | ||
|
||
``{{ item.name }}`` | ||
- **Default value:** ``{{ item.default }}`` | ||
|
||
**Value status:** {{ item.value_status }} | ||
|
||
**Liveness:** {{ item.liveness }} | ||
|
||
.. raw:: html | ||
|
||
<p>{{item.description}}</p> | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:orphan: | ||
|
||
======================= | ||
db/config.cc properties | ||
======================= | ||
|
||
.. datatemplate:yaml:: ../_data/db_config.yaml | ||
:template: db_config.tmpl |