Skip to content

Commit

Permalink
generate parameter tables from XML using MkDocs hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jimustafa committed May 9, 2024
1 parent bbf3f1c commit 64f6e08
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 354 deletions.
76 changes: 39 additions & 37 deletions docs/docs/parameters/generate-parameter-tables.py
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)
63 changes: 0 additions & 63 deletions docs/docs/parameters/parameters-csv2xml.py

This file was deleted.

31 changes: 0 additions & 31 deletions docs/docs/parameters/postw90-berry-parameters.csv

This file was deleted.

27 changes: 0 additions & 27 deletions docs/docs/parameters/postw90-boltzwann-parameters.csv

This file was deleted.

14 changes: 0 additions & 14 deletions docs/docs/parameters/postw90-dos-parameters.csv

This file was deleted.

4 changes: 0 additions & 4 deletions docs/docs/parameters/postw90-geninterp-parameters.csv

This file was deleted.

18 changes: 0 additions & 18 deletions docs/docs/parameters/postw90-global-parameters.csv

This file was deleted.

17 changes: 0 additions & 17 deletions docs/docs/parameters/postw90-gyrotropic-parameters.csv

This file was deleted.

5 changes: 0 additions & 5 deletions docs/docs/parameters/postw90-kpath-parameters.csv

This file was deleted.

9 changes: 0 additions & 9 deletions docs/docs/parameters/postw90-kslice-parameters.csv

This file was deleted.

12 changes: 0 additions & 12 deletions docs/docs/parameters/w90-disentanglement-parameters.csv

This file was deleted.

17 changes: 0 additions & 17 deletions docs/docs/parameters/w90-job-parameters.csv

This file was deleted.

Loading

0 comments on commit 64f6e08

Please sign in to comment.