Skip to content

Commit

Permalink
doc generation: Fix strings with invalid escape codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwebster committed Apr 15, 2024
1 parent 73015fd commit c56d766
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions docs/reference/cinnamon-js/gen_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@
JS_MISC_DIR = os.path.join(ROOT_DIR, 'js/misc/')

# Allow types like "object/string"
TYPE_REGEX = r'\w*\.?\w+/?\w*\.?\w*'
COMMENT_REGEX = re.compile(r'/\*([^*]|(\*[^/]))*\*+/')
RETURNS_REGEX = re.compile(r'^Returns\s*\(?(' + TYPE_REGEX + ')?\)?:(.*)')
INHERITS_REGEX = re.compile(r'^Inherits:\s*(' + TYPE_REGEX + ')\s*$')
PROPERTY_REGEX = re.compile(r'^@(\w+)\s*\(?(' + TYPE_REGEX + ')?\)?:(.*)')
RETURNS_REGEX = re.compile(r'^Returns\s*\(?(\w*\.?\w+/?\w*\.?\w*)?\)?:(.*)')
INHERITS_REGEX = re.compile(r'^Inherits:\s*(\w*\.?\w+/?\w*\.?\w*)\s*$')
PROPERTY_REGEX = re.compile(r'^@(\w+)\s*\(?(\w*\.?\w+/?\w*\.?\w*)?\)?:(.*)')
FILE_NAME_REGEX = re.compile(r'FILE:\s*(\w+\.js):?')
SIGNAL_NAME_REGEX = re.compile(r'SIGNAL:\s*([\w-]+):?')
ENUM_NAME_REGEX = re.compile(r'ENUM:\s*(\w+):?')
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/cinnamon-js/gen_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ def get_type_link(typ, file):
return typ.replace('.', '')

def markup(line, obj):
line = re.sub('@(\w*)', '<code>\g<1></code>', line)
line = re.sub('`([^`]*)`', '<code>\g<1></code>', line)
line = re.sub('\*\*([^*]*)\*\*', '<emphasis role="strong">\g<1></emphasis>', line)
line = re.sub('\*([^*]*)\*', '<emphasis>\g<1></emphasis>', line)
line = re.sub(r'@(\w*)', r'<code>\g<1></code>', line)
line = re.sub(r'`([^`]*)`', r'<code>\g<1></code>', line)
line = re.sub(r'\*\*([^*]*)\*\*', r'<emphasis role="strong">\g<1></emphasis>', line)
line = re.sub(r'\*([^*]*)\*', r'<emphasis>\g<1></emphasis>', line)

def format_type_link(match):
res = match.group(1)
return '<link linkend="{link}"><code>{name}</code></link>'.format(
link = get_type_link(res, obj.file),
name = res)

line = re.sub('#(([\w]*\.)?[\w]+)', format_type_link, line)
line = re.sub(r'#(([\w]*\.)?[\w]+)', format_type_link, line)

def format_ext_link(match):
if match.group(1):
Expand Down Expand Up @@ -96,7 +96,7 @@ def format_ext_link(match):
else:
return '<code>{name}</code>'.format(name = full)

line = re.sub('%(([\w]+\.)?[\w]+\.)?([\w]+)(\(\))?', format_ext_link, line)
line = re.sub(r'%(([\w]+\.)?[\w]+\.)?([\w]+)(\(\))?', format_ext_link, line)

return line

Expand Down

0 comments on commit c56d766

Please sign in to comment.