Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
build.Page Class Reference
Inheritance diagram for build.Page:
build.Artifact

Public Member Functions

 __init__ (self, str name)
 
 __repr__ (self)
 
 depends_on (self, str path)
 
 build (self)
 

Public Attributes

 name
 
 output
 
 inputs
 
- Public Attributes inherited from build.Artifact
 output
 
 inputs
 

Protected Member Functions

 _load_markdown (self)
 
 _update_xref_section (self, xrefs)
 

Additional Inherited Members

- Static Public Member Functions inherited from build.Artifact
 build_all ()
 
 build_matching (Callable[[Artifact], bool] predicate)
 
- Static Public Attributes inherited from build.Artifact
dict all = {}
 
list listeners = []
 

Detailed Description

A single wiki Page (a markdown file).

Definition at line 130 of file build.py.

Constructor & Destructor Documentation

◆ __init__()

build.Page.__init__ (   self,
str  name 
)

Reimplemented from build.Artifact.

Definition at line 133 of file build.py.

133 def __init__(self, name: str):
134 self.name = name
135 output_name = 'index' if name == 'README' else name
136 super().__init__(os.path.join(OUTPUT_DIR, f'{output_name}.html'),
137 [os.path.join(WIKI_SOURCE_DIR, f'{name}.md')])
138

Member Function Documentation

◆ __repr__()

build.Page.__repr__ (   self)

Definition at line 139 of file build.py.

139 def __repr__(self):
140 return f'Page({self.output} <- {self.inputs[0]})'
141

◆ _load_markdown()

build.Page._load_markdown (   self)
protected

Definition at line 146 of file build.py.

146 def _load_markdown(self):
147 with open(self.inputs[0], 'r', encoding='utf-8') as file:
148 content = file.read()
149
150 # Remove autogenerated xref section.
151 content = re.sub(r'<!\-\- AUTOGENERATED XREF SECTION \-\->.*$',
152 '',
153 content,
154 flags=re.DOTALL)
155
156 return convert_admonitions(content)
157

◆ _update_xref_section()

build.Page._update_xref_section (   self,
  xrefs 
)
protected

Definition at line 158 of file build.py.

158 def _update_xref_section(self, xrefs):
159 with open(self.inputs[0], 'r', encoding='utf-8') as file:
160 content = file.read()
161 section = '\n'.join(
162 ['', '<!-- AUTOGENERATED XREF SECTION -->'] +
163 [f'[{key}]: {value}' for key, value in xrefs.items()])
164 with open(self.inputs[0], 'w', encoding='utf-8') as file:
165 content = re.sub(r'\n<!-- AUTOGENERATED XREF SECTION -->.*$',
166 '',
167 content,
168 flags=re.DOTALL)
169 content += section
170 file.write(content)
171

◆ build()

build.Page.build (   self)
Convert artifact inputs into an output.

Reimplemented from build.Artifact.

Definition at line 172 of file build.py.

172 def build(self):
173 logging.info('Build %s from %s', self.output, self.inputs[0])
174
175 template = jinja2_env.get_template(PAGE_TEMPLATE)
176 md_converter = markdown.Markdown(extensions=[
177 'admonition',
178 'extra',
179 CodeHiliteExtension(),
180 'tables',
181 'pymdownx.superfences',
182 'toc',
183 xref_extension,
184 ])
185 result = template.render({
186 'dev':
187 is_dev_mode,
188 'body':
189 md_converter.convert(self._load_markdown()),
190 'root':
191 deployment_root
192 })
193 # pylint: disable=no-member
194 if not is_dev_mode and len(md_converter.xrefs) > 0:
195 self._update_xref_section(md_converter.xrefs)
196
197 os.makedirs(os.path.dirname(self.output), exist_ok=True)
198 with codecs.open(self.output, "w", encoding='utf-8') as file:
199 file.write(result)
200
201 template_filename = template.filename # pytype: disable=attribute-error
202 self.inputs = [self.inputs[0], template_filename]
203
204
Definition build.py:1

◆ depends_on()

build.Page.depends_on (   self,
str  path 
)
Check if this

Reimplemented from build.Artifact.

Definition at line 142 of file build.py.

142 def depends_on(self, path: str):
143 return path.startswith(TEMPLATES_INCLUDES_DIR) or super().depends_on(
144 path)
145
static bool depends_on(GrRenderTask *depender, GrRenderTask *dependee)

Member Data Documentation

◆ inputs

build.Page.inputs

Definition at line 202 of file build.py.

◆ name

build.Page.name

Definition at line 134 of file build.py.

◆ output

build.Page.output

Definition at line 173 of file build.py.


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