Docs: extend settings table
The settings table on the website now also includes type and default value of settings. Required extending the rstutils script.
This commit is contained in:
parent
95e8a269f5
commit
e023e05429
|
@ -50,17 +50,24 @@ class RSTFile:
|
|||
title: Title of the table.
|
||||
"""
|
||||
# Find out size of first column
|
||||
length = max([len(elem[0]) for elem in rows])
|
||||
ncols = len(rows[0])
|
||||
lengths = [max([len(elem[i]) for elem in rows]) for i in range(ncols)]
|
||||
empty_row = ["=" * n for n in lengths]
|
||||
|
||||
def format_row(row=empty_row):
|
||||
parts = " ".join(f"{elem:{n}s}" for elem, n in zip(row, lengths))
|
||||
return f" {parts}\n"
|
||||
|
||||
# Header
|
||||
self.write(".. table:: %s\n :widths: %s\n\n" % (title, widths))
|
||||
self.write(" %s ===========\n" % (length * "="))
|
||||
self.write(" %-*s %s\n" % (length, rows[0][0], rows[0][1]))
|
||||
self.write(" %s ===========\n" % (length * "="))
|
||||
self.write(f".. table:: {title}\n :widths: {widths}\n\n")
|
||||
self.write(format_row())
|
||||
self.write(format_row(rows[0]))
|
||||
self.write(format_row())
|
||||
# Content
|
||||
for row in rows[1:]:
|
||||
self.write(" %-*s %s\n" % (length, row[0], row[1]))
|
||||
self.write(format_row(row))
|
||||
# Footer
|
||||
self.write(" %s ===========\n" % (length * "="))
|
||||
self.write(format_row())
|
||||
|
||||
def _write_header(self):
|
||||
"""Write header to file explaining that the file was autogenerated."""
|
||||
|
|
|
@ -68,12 +68,15 @@ def generate_settings():
|
|||
print("generating settings...")
|
||||
filename = "docs/documentation/configuration/settings_table.rstsrc"
|
||||
with RSTFile(filename) as f:
|
||||
rows = [("Setting", "Description")]
|
||||
rows = [("Setting", "Description", "Default", "Type")]
|
||||
for name in sorted(api.settings._storage.keys()):
|
||||
setting = api.settings._storage[name]
|
||||
if setting.desc: # Otherwise the setting is meant to be hidden
|
||||
rows.append((name, setting.desc))
|
||||
f.write_table(rows, title="Overview of settings", widths="30 70")
|
||||
default = str(setting.default)
|
||||
if len(default) > 20: # Cut very long defaults (exif)
|
||||
default = default[:17] + "..."
|
||||
rows.append((name, setting.desc, default, setting.typ.__name__))
|
||||
f.write_table(rows, title="Overview of settings", widths="20 60 15 5")
|
||||
|
||||
|
||||
def generate_keybindings():
|
||||
|
|
Loading…
Reference in New Issue