Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
xrefs._XrefPattern Class Reference
Inheritance diagram for xrefs._XrefPattern:

Public Member Functions

def __init__ (self, md, SymbolsIndex symbols_index, Dict[str, str] packages)
 
def handleMatch (self, m, data)
 

Public Attributes

 symbols_index
 
 packages
 
 md
 

Static Public Attributes

string XREF_RE = r'\[`(?P<symbol>[^]]+)`\]?\[\]|\[(?P<text>[^]]*)\]\[`(?P<target>[^]]+)`\]'
 

Detailed Description

Converts xrefs into GitHub links.

Recognizes [`symbol`][] and [text][`symbol`] link formats where symbol
is expected to be one of the following:

* Fully qualified reference to a C++ class, method or function;
* Package URI pointing to one of the packages included in the SDK
checkout.
* File reference to one of the file in the SDK.

Definition at line 38 of file xrefs.py.

Constructor & Destructor Documentation

◆ __init__()

def xrefs._XrefPattern.__init__ (   self,
  md,
SymbolsIndex  symbols_index,
Dict[str, str]  packages 
)

Definition at line 52 of file xrefs.py.

53 packages: Dict[str, str]):
54 super().__init__(_XrefPattern.XREF_RE)
55 self.symbols_index = symbols_index
56 self.packages = packages
57 self.md = md
58

Member Function Documentation

◆ handleMatch()

def xrefs._XrefPattern.handleMatch (   self,
  m,
  data 
)

Definition at line 59 of file xrefs.py.

59 def handleMatch(self, m, data):
60 text = m.group('text')
61 symbol = m.group('symbol')
62 if symbol is None:
63 symbol = m.group('target')
64
65 uri = self._resolve_ref(symbol) or '#broken-link'
66
67 # Remember this xref. build process can later use this information
68 # to produce xref reference section at the end of the markdown file.
69 self.md.xrefs[f"`{symbol}`"] = uri
70
71 # Create <a href='uri'>text</a> element. If text is not defined
72 # simply use a slightly sanitized symbol name.
73 anchor = etree.Element('a')
74 anchor.attrib['href'] = uri
75 anchor.attrib['target'] = '_blank'
76 if text is not None:
77 anchor.text = text
78 else:
79 code = etree.Element('code')
80 code.text = re.sub(r'^dart::', '', symbol)
81 anchor.append(code)
82
83 # Replace the whole pattern match with anchor element.
84 return anchor, m.start(0), m.end(0)
85

Member Data Documentation

◆ md

xrefs._XrefPattern.md

Definition at line 57 of file xrefs.py.

◆ packages

xrefs._XrefPattern.packages

Definition at line 56 of file xrefs.py.

◆ symbols_index

xrefs._XrefPattern.symbols_index

Definition at line 55 of file xrefs.py.

◆ XREF_RE

string xrefs._XrefPattern.XREF_RE = r'\[`(?P<symbol>[^]]+)`\]?\[\]|\[(?P<text>[^]]*)\]\[`(?P<target>[^]]+)`\]'
static

Definition at line 50 of file xrefs.py.


The documentation for this class was generated from the following file: