20 This script allows to generate the markdown table displayed in doxygen 21 documentation of vtkMRMLColorLogic::AddDefaultColorNodes() 24 nodes = slicer.mrmlScene.GetNodesByClass(
"vtkMRMLColorNode")
25 nodes.UnRegister(slicer.mrmlScene)
27 template =
"/// | {family} | {category} | {_type} | {node_name} | {singleton_tag} | {node_id} |" 30 for 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()})
40 titles = {
'family':
'Family',
41 'category':
'Category',
43 'node_name':
'Node name',
44 'singleton_tag':
'Singleton Tag',
46 max_row_widths = {column_name: len(column_title)
for (column_name, column_title)
in titles.iteritems()}
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
55 for (column_name, column_width)
in max_row_widths.iteritems():
56 template = template.replace(column_name, column_name +
":%d" % column_width)
59 print(template.format(**titles))
62 print(template.format(**{column_name:
'-'*column_width
for column_name, column_width
in max_row_widths.iteritems()}))
66 print(template.format(**row) )