diff options
author | Themba Dube <embeddedthemba@gmail.com> | 2021-05-04 20:43:12 -0400 |
---|---|---|
committer | Themba Dube <embeddedthemba@gmail.com> | 2021-05-04 20:43:12 -0400 |
commit | e6b0b87e335aee91f9525b95e0fc023034e6252c (patch) | |
tree | afe197d0d3d1b923743e05d14f3dc821b9b26bb8 /docs/_ext/lv_example.py | |
parent | 528314533cc60070402297a923ff75c6be3f9854 (diff) | |
download | lvgl-e6b0b87e335aee91f9525b95e0fc023034e6252c.tar.gz lvgl-e6b0b87e335aee91f9525b95e0fc023034e6252c.zip |
docs(all) add live example for arc and PDF build
Diffstat (limited to 'docs/_ext/lv_example.py')
-rw-r--r-- | docs/_ext/lv_example.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/docs/_ext/lv_example.py b/docs/_ext/lv_example.py index 9e0cde96a..4e5557d44 100644 --- a/docs/_ext/lv_example.py +++ b/docs/_ext/lv_example.py @@ -16,16 +16,19 @@ class LvExample(Directive): if self.arguments[2] == 'py': paragraph_node = nodes.raw(text=f"Click to try in the simulator!<br/><a target='_blank' href='https://sim.lvgl.io/v7/micropython/ports/javascript/bundle_out/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lv_examples/{env.config.example_commit_hash}/src/header.py&script=https://raw.githubusercontent.com/lvgl/lv_examples/{env.config.built_example_commit_hash}/{example_name}/{example_name}.py'><img alt='{example_name}' src='https://raw.githubusercontent.com/lvgl/lv_examples/{env.config.built_example_commit_hash}/{example_name}/{example_name}.png'/></a>", format='html') else: - paragraph_node = nodes.raw(text=f"<iframe class='lv-example' src='../_static/built_lv_examples/{example_name}/?w=320&h=240'></iframe>", format='html') + paragraph_node = nodes.raw(text=f"<iframe class='lv-example' src='../../_static/built_lv_examples?example={example_name}&w=320&h=240'></iframe>", format='html') toggle = nodes.container('', literal_block=False, classes=['toggle']) header = nodes.container('', literal_block=False, classes=['header']) toggle.append(header) - example_file = os.path.abspath("lv_examples/src/" + example_path + "." + self.arguments[2]) + example_file = os.path.abspath("../examples/" + example_path + "." + self.arguments[2]) - with open(example_file) as f: - contents = f.read() - literal_list = nodes.literal_block(contents, contents) - literal_list['language'] = self.arguments[2] + try: + with open(example_file) as f: + contents = f.read() + except FileNotFoundError: + contents = 'Error encountered while trying to open ' + example_file + literal_list = nodes.literal_block(contents, contents) + literal_list['language'] = self.arguments[2] toggle.append(literal_list) header.append(nodes.paragraph(text="code")) if env.app.tags.has('html'): |