Cleaned up code for the window list.
This commit is contained in:
parent
50a01f3376
commit
d852e87bd6
2 changed files with 27 additions and 37 deletions
|
@ -210,10 +210,10 @@ const std::string& tgui_definition::read(const config& cfg)
|
|||
* @end_table
|
||||
*
|
||||
* <span id="window_list"></span>List of available windows:
|
||||
* @start_table = window_definition
|
||||
* addon_connect The dialog to connect to the addon server
|
||||
* @start_table = window_overview
|
||||
* Addon_connect The dialog to connect to the addon server
|
||||
* and maintain locally installed addons.
|
||||
* language_selection The dialog to select the primairy language.
|
||||
* Language_selection The dialog to select the primairy language.
|
||||
* @end_table
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -182,31 +182,6 @@ if __name__ == "__main__":
|
|||
|
||||
return result
|
||||
|
||||
# FIXME remove after create_window_definition_table has been converted.
|
||||
def create_widget_definition_table(data):
|
||||
"""Creates a table for a widget definition."""
|
||||
|
||||
#matches a line like
|
||||
# button_definition A push button.
|
||||
variable = "(?:[a-z]|[A-Z])(?:[a-z]|[A-Z]|[0-9]|_)*"
|
||||
regex = re.compile(" *(" + variable + ") +(.*)\n")
|
||||
res = regex.findall(data)
|
||||
|
||||
# empty table
|
||||
if(len(res) == 0):
|
||||
sys.stderr.write("Empty table:\n" + data + "\n")
|
||||
return "Empty table."
|
||||
|
||||
result = '{| border="1"'
|
||||
result += "\n!Section\n!description\n"
|
||||
for i in range(len(res)):
|
||||
result += "|-\n"
|
||||
result += "| " + res[i][0] + "\n"
|
||||
result += "| " + format(res[i][1]) + "\n"
|
||||
result += "|}"
|
||||
|
||||
return result
|
||||
|
||||
def create_widget_overview_table(data):
|
||||
"""Creates a table for all available widgets."""
|
||||
#matches a line like
|
||||
|
@ -233,16 +208,31 @@ if __name__ == "__main__":
|
|||
|
||||
return result
|
||||
|
||||
|
||||
def create_window_definition_table(data):
|
||||
"""Creates a table for a window definition."""
|
||||
|
||||
def create_window_overview_table(data):
|
||||
"""Creates a table for all available windows."""
|
||||
#matches a line like
|
||||
# addon_connect The dialog to connect to the addon server
|
||||
# Addon_connect The dialog to connect to the addon server
|
||||
variable = "(?:[a-z]|[A-Z])(?:[a-z]|[A-Z]|[0-9]|_)*"
|
||||
regex = re.compile(" *(" + variable + ") +(.*)\n")
|
||||
res = regex.findall(data)
|
||||
|
||||
# atm we look the same as the widget table
|
||||
return create_widget_definition_table(data)
|
||||
# empty table
|
||||
if(len(res) == 0):
|
||||
sys.stderr.write("Empty table:\n" + data + "\n")
|
||||
return "Empty table."
|
||||
|
||||
result = '{| border="1"'
|
||||
result += "\n!Section\n!Description\n"
|
||||
for i in range(len(res)):
|
||||
result += "|-\n"
|
||||
result += "| " + re.sub(r'_', ' ', res[i][0])
|
||||
result += " ([[GUIWindowDefinitionWML#"
|
||||
result += res[i][0]
|
||||
result += "|definition]])\n"
|
||||
result += "| " + format(res[i][1]) + "\n"
|
||||
result += "|}"
|
||||
|
||||
return result
|
||||
|
||||
def create_container_table(data):
|
||||
"""Creates a table for a container."""
|
||||
|
@ -316,8 +306,8 @@ if __name__ == "__main__":
|
|||
return create_variable_types_table(table.group(2) + "\n")
|
||||
elif(type == "widget_overview"):
|
||||
return create_widget_overview_table(table.group(2) + "\n")
|
||||
elif(type == "window_definition"):
|
||||
return create_window_definition_table(table.group(2) + "\n")
|
||||
elif(type == "window_overview"):
|
||||
return create_window_overview_table(table.group(2) + "\n")
|
||||
elif(type == "container"):
|
||||
return create_container_table(table.group(2) + "\n")
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue