MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / markup

Method markup

tools/python-3.11.9-amd64/Lib/pydoc.py:713–752  ·  view source on GitHub ↗

Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.

(self, text, escape=None, funcs={}, classes={}, methods={})

Source from the content-addressed store, hash-verified

711 return '<a href="file:%s">%s</a>' % (url, path)
712
713 def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
714 """Mark up some plain text, given a context of symbols to look for.
715 Each context dictionary maps object names to anchor names."""
716 escape = escape or self.escape
717 results = []
718 here = 0
719 pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|'
720 r'RFC[- ]?(\d+)|'
721 r'PEP[- ]?(\d+)|'
722 r'(self\.)?(\w+))')
723 while True:
724 match = pattern.search(text, here)
725 if not match: break
726 start, end = match.span()
727 results.append(escape(text[here:start]))
728
729 all, scheme, rfc, pep, selfdot, name = match.groups()
730 if scheme:
731 url = escape(all).replace('"', '&quot;')
732 results.append('<a href="%s">%s</a>' % (url, url))
733 elif rfc:
734 url = 'https://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
735 results.append('<a href="%s">%s</a>' % (url, escape(all)))
736 elif pep:
737 url = 'https://peps.python.org/pep-%04d/' % int(pep)
738 results.append('<a href="%s">%s</a>' % (url, escape(all)))
739 elif selfdot:
740 # Create a link for methods like 'self.method(...)'
741 # and use <strong> for attributes like 'self.attr'
742 if text[end:end+1] == '(':
743 results.append('self.' + self.namelink(name, methods))
744 else:
745 results.append('self.<strong>%s</strong>' % name)
746 elif text[end:end+1] == '(':
747 results.append(self.namelink(name, methods, funcs, classes))
748 else:
749 results.append(self.namelink(name, classes))
750 here = end
751 results.append(escape(text[here:]))
752 return ''.join(results)
753
754 # ---------------------------------------------- type-specific routines
755

Callers 6

docmoduleMethod · 0.95
spilldataMethod · 0.95
docclassMethod · 0.95
docroutineMethod · 0.95
docdataMethod · 0.95
html_topicpageFunction · 0.45

Calls 9

namelinkMethod · 0.95
spanMethod · 0.80
escapeFunction · 0.70
compileMethod · 0.45
searchMethod · 0.45
appendMethod · 0.45
groupsMethod · 0.45
replaceMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected