-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate parameter tables from XML using MkDocs hook
- Loading branch information
Showing
17 changed files
with
42 additions
and
354 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
import pathlib | ||
import xml.etree.ElementTree as ET | ||
|
||
|
||
groups = { | ||
'w90': [ | ||
'disentanglement', | ||
'job', | ||
'plot', | ||
'system', | ||
'transport', | ||
'wannierise', | ||
], | ||
'postw90': [ | ||
'berry', | ||
'boltzwann', | ||
'dos', | ||
'geninterp', | ||
'global', | ||
'gyrotropic', | ||
'kpath', | ||
'kslice', | ||
], | ||
} | ||
def on_pre_build(config): | ||
groups = { | ||
'w90': [ | ||
'disentanglement', | ||
'job', | ||
'plot', | ||
'system', | ||
'transport', | ||
'wannierise', | ||
], | ||
'postw90': [ | ||
'berry', | ||
'boltzwann', | ||
'dos', | ||
'geninterp', | ||
'global', | ||
'gyrotropic', | ||
'kpath', | ||
'kslice', | ||
], | ||
} | ||
|
||
tree = ET.parse('parameters.xml') | ||
root = tree.getroot() | ||
tree = ET.parse(pathlib.Path(config.docs_dir)/'parameters/parameters.xml') | ||
root = tree.getroot() | ||
|
||
for tool in ['w90', 'postw90']: | ||
for group in groups[tool]: | ||
parameters = root.findall(f'./parameter[@tool="{tool}"][@group="{group}"]') | ||
with open(f'{tool}-{group}-parameters.csv', 'w') as fp: | ||
print('Keyword,Type,Description', file=fp) | ||
for parameter in parameters: | ||
name = parameter.find('name') | ||
type = parameter.find('type') | ||
description = parameter.find('description') | ||
if 'optional_prefix' in name.attrib: | ||
print(f'[{name.attrib["optional_prefix"]}]{name.text},', end='', file=fp) | ||
else: | ||
print(f'{name.text},', end='', file=fp) | ||
print(f'{type.text},', end='', file=fp) | ||
print(f'"{description.text}"', file=fp) | ||
for tool in ['w90', 'postw90']: | ||
for group in groups[tool]: | ||
parameters = root.findall(f'./parameter[@tool="{tool}"][@group="{group}"]') | ||
with open(pathlib.Path(config.docs_dir)/f'parameters/{tool}-{group}-parameters.csv', 'w') as fp: | ||
print('Keyword,Type,Description', file=fp) | ||
for parameter in parameters: | ||
name = parameter.find('name') | ||
type = parameter.find('type') | ||
description = parameter.find('description') | ||
if 'optional_prefix' in name.attrib: | ||
print(f'[{name.attrib["optional_prefix"]}]{name.text},', end='', file=fp) | ||
else: | ||
print(f'{name.text},', end='', file=fp) | ||
print(f'{type.text},', end='', file=fp) | ||
print(f'"{description.text}"', file=fp) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.