20 This script allows to generate the markdown table displayed in doxygen 21 documentation of vtkMRMLColorLogic::AddDefaultColorNodes() 23 from __future__
import print_function
25 nodes = slicer.mrmlScene.GetNodesByClass(
"vtkMRMLColorNode")
26 nodes.UnRegister(slicer.mrmlScene)
28 template =
"/// | {family} | {category} | {_type} | {node_name} | {singleton_tag} | {node_id} |" 31 for index
in range(nodes.GetNumberOfItems()):
32 n = nodes.GetItemAsObject(index)
34 'family': n.GetClassName().replace(
'vtkMRML',
'').replace(
'Node',
''),
35 'category': n.GetAttribute(
"Category"),
36 '_type': n.GetTypeAsString(),
37 'node_name': n.GetName(),
38 'singleton_tag': n.GetSingletonTag(),
39 'node_id': n.GetID()})
41 titles = {
'family':
'Family',
42 'category':
'Category',
44 'node_name':
'Node name',
45 'singleton_tag':
'Singleton Tag',
47 max_row_widths = {column_name: len(column_title)
for (column_name, column_title)
in titles.items()}
50 for column_name
in max_row_widths.keys():
51 column_width = len(str(row[column_name]))
52 if column_width > max_row_widths[column_name]:
53 max_row_widths[column_name] = column_width
56 for (column_name, column_width)
in max_row_widths.items():
57 template = template.replace(column_name, column_name +
":%d" % column_width)
60 print(template.format(**titles))
63 print(template.format(**{column_name:
'-'*column_width
for column_name, column_width
in max_row_widths.items()}))
67 print(template.format(**row) )