Author: mordante
Date: Thu Apr 14 20:39:36 2011
New Revision: 49198
URL: http://svn.gna.org/viewcvs/wesnoth?rev=49198&view=rev
Log:
Improve widget_overview wiki comment handling.
- Uses a new way to get the regex.
- Allow `nicer' line wrapping.
The next commit will update the formatting used, the output remains
unchanged with this commit.
Modified:
trunk/utils/wiki_grabber.py
Modified: trunk/utils/wiki_grabber.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/wiki_grabber.py?rev=49198&r1=49197&r2=49198&view=diff
==============================================================================
--- trunk/utils/wiki_grabber.py (original)
+++ trunk/utils/wiki_grabber.py Thu Apr 14 20:39:36 2011
@@ -73,6 +73,13 @@
# current block being processed
current_block = ""
+ re_record_start = '^\s*'
+ re_field_separator = '\s+&\s+' # Todo make & & work as well
+ re_record_end = '\s+\$$'
+
+ re_variable = '([a-zA-Z]\w*)'
+ re_string = '(.*?)'
+
def is_empty(res, data):
"""
This checks whether or not a table is empty and writes to stderr if it
is.
@@ -135,8 +142,12 @@
def format(data):
"""Formats the data for the wiki.
- @* -> \n* needed in a list.
- @- -> \n needed to add text after a list."""
+ Replaces the following:
+ - An end of line and its surrounding whitespace to a single space.
+ - @* -> \n* needed in a list.
+ - @- -> \n needed to add text after a list.
+ """
+ data = re.sub(r'\s*\n\s*', ' ', data)
data = re.sub(r'@\*', "\n*", data)
data = re.sub(r'@\-', "\n", data)
return data
@@ -223,9 +234,13 @@
def create_widget_overview_table(data):
"""Creates a table for all available widgets."""
- #matches a line like
- # Button & A push button. $
- regex = re.compile("([A-Za-z]\w*) +& +(.*) +\$")
+
+ regex = re_record_start
+ regex += re_variable # widget type
+ regex += re_field_separator
+ regex += re_string # description
+ regex += re_record_end
+ regex = re.compile(regex, re.DOTALL | re.MULTILINE)
res = regex.findall(data)
if is_empty(res, data):
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits