20This script allows to generate the markdown table displayed in doxygen
21documentation of vtkMRMLColorLogic::AddDefaultColorNodes()
24nodes = slicer.mrmlScene.GetNodesByClass(
"vtkMRMLColorNode")
25nodes.UnRegister(slicer.mrmlScene)
27template =
"/// | {family} | {category} | {_type} | {node_name} | {singleton_tag} | {node_id} |"
30for index
in range(nodes.GetNumberOfItems()):
31 n = nodes.GetItemAsObject(index)
33 "family": n.GetClassName().replace(
"vtkMRML",
"").replace(
"Node",
""),
34 "category": n.GetAttribute(
"Category"),
35 "_type": n.GetTypeAsString(),
36 "node_name": n.GetName(),
37 "singleton_tag": n.GetSingletonTag(),
38 "node_id": n.GetID()})
40titles = {
"family":
"Family",
41 "category":
"Category",
43 "node_name":
"Node name",
44 "singleton_tag":
"Singleton Tag",
46max_row_widths = {column_name: len(column_title)
for (column_name, column_title)
in titles.items()}
49 for column_name
in max_row_widths.keys():
50 column_width = len(str(row[column_name]))
51 if column_width > max_row_widths[column_name]:
52 max_row_widths[column_name] = column_width
55for column_name, column_width
in max_row_widths.items():
56 template = template.replace(column_name, column_name +
":%d" % column_width)
59print(template.format(**titles))
62print(template.format(**{column_name:
"-" * column_width
for column_name, column_width
in max_row_widths.items()}))
66 print(template.format(**row))