mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-28 14:51:36 +00:00
UDBScript: Map class: the getSidedefsFromSelectedLinedefs() method now correctly only returns the Sidedefs of selected Linedefs in visual mode (and not also the highlighted one) UDBScript: Map class: added a new getSidedefsFromSelectedOrHighlightedLinedefs() method as the equivalent to the other getSelectedOrHighlighted*() methods UDBScript: Sector class: added new floorSelected, ceilingSelected, floorHighlighted, and ceilingHighlighted properties. Those are mostly useful in visual mode, since they always return true when the Sector is selected or highlighted in the classic modes. The properties are read-only UDBScript: Sidedef class: added new upperSelected, middleSelected, lowerSelected, upperHighlighted, middleHighlighted, and lowerHighlighted properties. Those are mostly useful in visual mode, since they always return true when the parent Linedef is selected or highlighted in the classic modes. The properties are read-only UDBScript: added new example to apply textures for floor/ceiling and upper/middle/lower texture for selected map elements UDBScript: updated documentation
126 lines
No EOL
5.4 KiB
Python
126 lines
No EOL
5.4 KiB
Python
import xmltodict
|
|
import glob
|
|
import pprint
|
|
import re
|
|
|
|
pp = pprint.PrettyPrinter(indent=4)
|
|
|
|
def determine_text_type(text):
|
|
signature = text.replace('public ', '').replace ('static ', '').replace('Wrapper', '')
|
|
if 'class ' in text or 'struct ' in text:
|
|
return 'global', None
|
|
if '(' not in text:
|
|
return 'properties', re.sub(r'[^\s]+\s+', r'', signature).rstrip(';')
|
|
signaturefields = signature.split('(')
|
|
signature = re.sub(r'[^\s]+\s+', r'', signaturefields[0]) + '(' + re.sub(r'([^\s]+) ([^,]+)(,?\s*)', r'\2\3', signaturefields[1])
|
|
fields = text.split()
|
|
if fields[0] == 'public' and ('Wrapper(' in fields[1] or 'QueryOptions(' in fields[1]):
|
|
return 'constructors', signature
|
|
elif fields[1] == 'static':
|
|
return 'staticmethods', signature
|
|
return 'methods', signature
|
|
|
|
def get_sorted_comment_texts(texts):
|
|
text = ''
|
|
for t in sorted(texts.keys()):
|
|
text += texts[t]
|
|
return text
|
|
|
|
topics = {
|
|
'GameConfiguration': [ '../API/GameConfigurationWrapper.cs' ],
|
|
'Angle2D': [ '../API/Angle2DWrapper.cs' ],
|
|
'Data': [ '../API/DataWrapper.cs' ],
|
|
'ImageInfo': [ '../API/ImageInfo.cs' ],
|
|
'Line2D': [ '../API/Line2DWrapper.cs' ],
|
|
'Linedef': [ '../API/LinedefWrapper.cs', '../API/MapElementWrapper.cs' ],
|
|
'Map': [ '../API/MapWrapper.cs' ],
|
|
'Sector': [ '../API/SectorWrapper.cs', '../API/MapElementWrapper.cs' ],
|
|
'Sidedef': [ '../API/SidedefWrapper.cs', '../API/MapElementWrapper.cs' ],
|
|
'Thing': [ '../API/ThingWrapper.cs', '../API/MapElementWrapper.cs' ],
|
|
'Vector2D': [ '../API/Vector2DWrapper.cs' ],
|
|
'Vector3D': [ '../API/Vector3DWrapper.cs' ],
|
|
'Vertex': [ '../API/VertexWrapper.cs', '../API/MapElementWrapper.cs' ],
|
|
'QueryOptions': [ '../QueryOptions.cs' ],
|
|
}
|
|
|
|
for topic in topics:
|
|
texts = {
|
|
'global': '',
|
|
'properties': {},
|
|
'constructors': {},
|
|
'methods': {},
|
|
'staticmethods': {}
|
|
}
|
|
for filename in topics[topic]:
|
|
topicname = filename.split('\\')[-1].replace('Wrapper.cs', '')
|
|
|
|
with open(filename, 'r') as file:
|
|
xmltext = ''
|
|
parsingcomment = False
|
|
incodeblock = False
|
|
for line in file:
|
|
line = line.strip()
|
|
if line.startswith('///'):
|
|
parsingcomment = True
|
|
line = re.sub(r'^\t', r'', line.lstrip('/').lstrip(' '))
|
|
if line.startswith('```'):
|
|
if incodeblock:
|
|
xmltext += '```\n'
|
|
incodeblock = False
|
|
else:
|
|
xmltext += '\n```js\n'
|
|
incodeblock = True
|
|
else:
|
|
xmltext += line + '\n'
|
|
elif parsingcomment is True:
|
|
commenttext = ''
|
|
d = xmltodict.parse('<d>' + xmltext + '</d>')['d']
|
|
summary = d['summary']
|
|
texttype, signature = determine_text_type(line)
|
|
if texttype == 'global':
|
|
texts['global'] = f'{summary}\n'
|
|
else:
|
|
commenttext += '\n---\n'
|
|
if 'version' in d:
|
|
commenttext += f'<span style="float:right;font-weight:normal;font-size:66%">Version: {d["version"]}</span>\n'
|
|
commenttext += f'### {signature}\n'
|
|
|
|
commenttext += f'{summary}\n'
|
|
if 'param' in d:
|
|
commenttext += '#### Parameters\n'
|
|
if isinstance(d['param'], list):
|
|
for p in d['param']:
|
|
text = '*missing*'
|
|
if '#text' in p:
|
|
text = p['#text']
|
|
commenttext += f'* {p["@name"]}: {text}\n'
|
|
else:
|
|
text ='*missing*'
|
|
if '#text' in d['param']:
|
|
text = d['param']['#text'].replace('```', '\n```\n')
|
|
commenttext += f'* {d["param"]["@name"]}: {text}\n'
|
|
if 'returns' in d:
|
|
commenttext += '#### Return value\n'
|
|
text = '*missing*'
|
|
if d['returns'] is not None:
|
|
text = d['returns']
|
|
commenttext += f'{text}\n'
|
|
|
|
if signature not in texts[texttype]:
|
|
texts[texttype][signature] = ''
|
|
texts[texttype][signature] += commenttext
|
|
xmltext = ''
|
|
parsingcomment = False
|
|
|
|
outfile = open(f'htmldoc/docs/{topic}.md', 'w')
|
|
outfile.write(f'# {topic}\n\n')
|
|
outfile.write(f'{texts["global"]}')
|
|
if len(texts["constructors"]) > 0:
|
|
outfile.write(f'## Constructors\n{get_sorted_comment_texts(texts["constructors"])}')
|
|
if len(texts["staticmethods"]) > 0:
|
|
outfile.write(f'## Static methods\n{get_sorted_comment_texts(texts["staticmethods"])}')
|
|
if len(texts["properties"]) > 0:
|
|
outfile.write(f'## Properties\n{get_sorted_comment_texts(texts["properties"])}')
|
|
if len(texts["methods"]) > 0:
|
|
outfile.write(f'## Methods\n{get_sorted_comment_texts(texts["methods"])}')
|
|
outfile.close() |