summaryrefslogtreecommitdiff
path: root/doc/tools
diff options
context:
space:
mode:
Diffstat (limited to 'doc/tools')
-rwxr-xr-x[-rw-r--r--]doc/tools/doc_merge.py0
-rwxr-xr-x[-rw-r--r--]doc/tools/doc_status.py26
-rwxr-xr-xdoc/tools/makerst.py110
3 files changed, 74 insertions, 62 deletions
diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py
index 496d5dcb74..496d5dcb74 100644..100755
--- a/doc/tools/doc_merge.py
+++ b/doc/tools/doc_merge.py
diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py
index 6e34cffc05..e6e6d5f606 100644..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 ef38299680..9012de03b3 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -14,7 +14,7 @@ GODOT_DOCS_PATTERN = re.compile(r'^http(?:s)?://docs\.godotengine\.org/(?:[a-zA-
def print_error(error, state): # type: (str, State) -> None
- print(error)
+ print("ERROR: {}".format(error))
state.errored = True
@@ -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
@@ -148,6 +143,8 @@ class State:
setter = property.get("setter") or None # Use or None so '' gets turned into None.
getter = property.get("getter") or None
default_value = property.get("default") or None
+ if default_value is not None:
+ 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)
@@ -391,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', '-'))
@@ -492,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', '-'))
@@ -622,6 +614,40 @@ def make_class_list(class_list, columns): # type: (List[str], int) -> None
f.close()
+def escape_rst(text, until_pos=-1): # type: (str) -> str
+ # Escape \ character, otherwise it ends up as an escape character in rst
+ pos = 0
+ while True:
+ pos = text.find('\\', pos, until_pos)
+ if pos == -1:
+ break
+ text = text[:pos] + "\\\\" + text[pos + 1:]
+ pos += 2
+
+ # Escape * character to avoid interpreting it as emphasis
+ pos = 0
+ while True:
+ pos = text.find('*', pos, until_pos)
+ if pos == -1:
+ break
+ text = text[:pos] + "\*" + text[pos + 1:]
+ pos += 2
+
+ # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink
+ pos = 0
+ while True:
+ pos = text.find('_', pos, until_pos)
+ if pos == -1:
+ break
+ if not text[pos + 1].isalnum(): # don't escape within a snake_case word
+ text = text[:pos] + "\_" + text[pos + 1:]
+ pos += 2
+ else:
+ pos += 1
+
+ return text
+
+
def rstize_text(text, state): # type: (str, State) -> str
# Linebreak + tabs in the XML should become two line breaks unless in a "codeblock"
pos = 0
@@ -677,36 +703,7 @@ def rstize_text(text, state): # type: (str, State) -> str
pos += 2
next_brac_pos = text.find('[')
-
- # Escape \ character, otherwise it ends up as an escape character in rst
- pos = 0
- while True:
- pos = text.find('\\', pos, next_brac_pos)
- if pos == -1:
- break
- text = text[:pos] + "\\\\" + text[pos + 1:]
- pos += 2
-
- # Escape * character to avoid interpreting it as emphasis
- pos = 0
- while True:
- pos = text.find('*', pos, next_brac_pos)
- if pos == -1:
- break
- text = text[:pos] + "\*" + text[pos + 1:]
- pos += 2
-
- # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink
- pos = 0
- while True:
- pos = text.find('_', pos, next_brac_pos)
- if pos == -1:
- break
- if not text[pos + 1].isalnum(): # don't escape within a snake_case word
- text = text[:pos] + "\_" + text[pos + 1:]
- pos += 2
- else:
- pos += 1
+ text = escape_rst(text, next_brac_pos)
# Handle [tags]
inside_code = False
@@ -879,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
@@ -975,7 +973,11 @@ def make_enum(t, state): # type: (str, State) -> str
if c in state.classes and e in state.classes[c].enums:
return ":ref:`{0}<enum_{1}_{0}>`".format(e, c)
- print_error("Unresolved enum '{}', file: {}".format(t, state.current_class), state)
+
+ # Don't fail for `Vector3.Axis`, as this enum is a special case which is expected not to be resolved.
+ if "{}.{}".format(c, e) != "Vector3.Axis":
+ print_error("Unresolved enum '{}', file: {}".format(t, state.current_class), state)
+
return t