diff options
Diffstat (limited to 'doc/tools')
-rwxr-xr-x | doc/tools/doc_status.py | 26 | ||||
-rwxr-xr-x | doc/tools/makerst.py | 37 |
2 files changed, 32 insertions, 31 deletions
diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index 6e34cffc05..e6e6d5f606 100755 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -69,8 +69,8 @@ long_flags = { 'empty': 'e', } -table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals'] -table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals'] +table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals', 'theme_items'] +table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals', 'Theme Items'] colors = { 'name': [36], # cyan 'part_big_problem': [4, 31], # underline, red @@ -81,6 +81,7 @@ colors = { 'section': [1, 4], # bold, underline 'state_off': [36], # cyan 'state_on': [1, 35], # bold, magenta/plum + 'bold': [1], # bold } overall_progress_description_weigth = 10 @@ -176,6 +177,7 @@ class ClassStatus: 'methods': ClassStatusProgress(), 'constants': ClassStatusProgress(), 'members': ClassStatusProgress(), + 'theme_items': ClassStatusProgress(), 'signals': ClassStatusProgress() } @@ -220,13 +222,13 @@ class ClassStatus: ) items_progress = ClassStatusProgress() - for k in ['methods', 'constants', 'members', 'signals']: + for k in ['methods', 'constants', 'members', 'signals', 'theme_items']: items_progress += self.progresses[k] output[k] = self.progresses[k].to_configured_colored_string() output['items'] = items_progress.to_configured_colored_string() - output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}') + output['overall'] = (description_progress + items_progress).to_colored_string(color('bold', '{percent}%'), '{pad_percent}{s}') if self.name.startswith('Total'): output['url'] = color('url', 'https://docs.godotengine.org/en/latest/classes/') @@ -257,7 +259,7 @@ class ClassStatus: for sub_tag in list(tag): descr = sub_tag.find('description') status.progresses[tag.tag].increment(len(descr.text.strip()) > 0) - elif tag.tag in ['constants', 'members']: + elif tag.tag in ['constants', 'members', 'theme_items']: for sub_tag in list(tag): if not sub_tag.text is None: status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0) @@ -300,7 +302,7 @@ for arg in sys.argv[1:]: sys.exit(1) if flags['i']: - for r in ['methods', 'constants', 'members', 'signals']: + for r in ['methods', 'constants', 'members', 'signals', 'theme_items']: index = table_columns.index(r) del table_column_names[index] del table_columns[index] @@ -308,7 +310,7 @@ if flags['i']: table_columns.append('items') if flags['o'] == (not flags['i']): - table_column_names.append('Overall') + table_column_names.append(color('bold', 'Overall')) table_columns.append('overall') if flags['u']: @@ -434,6 +436,11 @@ if len(table) > 2 or not flags['a']: row.append('') table.append(row) +if flags['a']: + # Duplicate the headers at the bottom of the table so they can be viewed + # without having to scroll back to the top. + table.append(table_column_names) + table_column_sizes = [] for row in table: for cell_i, cell in enumerate(row): @@ -459,7 +466,10 @@ for row_i, row in enumerate(table): print(row_string) - if row_i == 0 or row_i == len(table) - 2: + # Account for the possible double header (if the `a` flag is enabled). + # No need to have a condition for the flag, as this will behave correctly + # if the flag is disabled. + if row_i == 0 or row_i == len(table) - 3 or row_i == len(table) - 2: print(divider_string) print(divider_string) diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 91240e9550..9012de03b3 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -98,7 +98,6 @@ class ClassDef: self.methods = OrderedDict() # type: OrderedDict[str, List[MethodDef]] self.signals = OrderedDict() # type: OrderedDict[str, SignalDef] self.inherits = None # type: Optional[str] - self.category = None # type: Optional[str] self.brief_description = None # type: Optional[str] self.description = None # type: Optional[str] self.theme_items = None # type: Optional[OrderedDict[str, List[ThemeItemDef]]] @@ -122,10 +121,6 @@ class State: if inherits is not None: class_def.inherits = inherits - category = class_root.get("category") - if category is not None: - class_def.category = category - brief_desc = class_root.find("brief_description") if brief_desc is not None and brief_desc.text: class_def.brief_description = brief_desc.text @@ -149,7 +144,7 @@ class State: getter = property.get("getter") or None default_value = property.get("default") or None if default_value is not None: - default_value = escape_rst(default_value) + default_value = '``{}``'.format(default_value) overridden = property.get("override") or False property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value, overridden) @@ -393,15 +388,22 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write(make_type(child, state)) f.write("\n\n") - # Category - if class_def.category is not None: - f.write('**Category:** ' + class_def.category.strip() + "\n\n") - # Brief description - f.write(make_heading('Brief Description', '-')) if class_def.brief_description is not None: f.write(rstize_text(class_def.brief_description.strip(), state) + "\n\n") + # Class description + if class_def.description is not None and class_def.description.strip() != '': + f.write(make_heading('Description', '-')) + f.write(rstize_text(class_def.description.strip(), state) + "\n\n") + + # Online tutorials + if len(class_def.tutorials) > 0: + f.write(make_heading('Tutorials', '-')) + for t in class_def.tutorials: + link = t.strip() + f.write("- " + make_url(link) + "\n\n") + # Properties overview if len(class_def.properties) > 0: f.write(make_heading('Properties', '-')) @@ -494,18 +496,6 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write('\n\n') - # Class description - if class_def.description is not None and class_def.description.strip() != '': - f.write(make_heading('Description', '-')) - f.write(rstize_text(class_def.description.strip(), state) + "\n\n") - - # Online tutorials - if len(class_def.tutorials) > 0: - f.write(make_heading('Tutorials', '-')) - for t in class_def.tutorials: - link = t.strip() - f.write("- " + make_url(link) + "\n\n") - # Property descriptions if any(not p.overridden for p in class_def.properties.values()) > 0: f.write(make_heading('Property Descriptions', '-')) @@ -886,6 +876,7 @@ def rstize_text(text, state): # type: (str, State) -> str inside_code = True elif cmd.startswith('enum '): tag_text = make_enum(cmd[5:], state) + escape_post = True else: tag_text = make_type(tag_text, state) escape_post = True |