docs(all) add live example for arc and PDF build

This commit is contained in:
Themba Dube 2021-05-04 20:43:12 -04:00
parent 528314533c
commit e6b0b87e33
6 changed files with 27 additions and 43 deletions

3
.gitignore vendored
View File

@ -8,6 +8,9 @@ scripts/cppcheck_res.txt
scripts/built_in_font/lv_font_*
docs/doxygen_html
docs/xml
docs/out_latex
docs/_static/built_lv_examples
docs/LVGL.pdf
out_html
__pycache__
/emscripten_builder

View File

@ -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'):

View File

@ -57,12 +57,12 @@ cmd("cd ../scripts && doxygen Doxyfile")
# Silly workarond to include the more or less correct PDF download link in the PDF
#cmd("cp -f " + lang +"/latex/LVGL.pdf LVGL.pdf | true")
#cmd("sphinx-build -b latex . en/latex")
cmd("sphinx-build -b latex . out_latex")
# Generat PDF
#cmd("cd " + lang + "/latex && xelatex -interaction=batchmode *.tex")
# Copy the result PDF to the main diractory to make it avaiable for the HTML build
#cmd("cd " + lang + "/latex && cp -f LVGL.pdf ../../LVGL.pdf")
# Generate PDF
cmd("cd out_latex && xelatex -interaction=batchmode *.tex")
# Copy the result PDF to the main directory to make it avaiable for the HTML build
cmd("cd out_latex && cp -f LVGL.pdf ../LVGL.pdf")
# BULD HTML
cmd("sphinx-build -b html . ../out_html")

View File

@ -43,7 +43,7 @@ extensions = ['sphinx.ext.autodoc',
'sphinx_markdown_tables',
'breathe',
'sphinx_sitemap',
#'lv_example'
'lv_example'
]
# Add any paths that contain templates here, relative to this directory.
@ -67,7 +67,7 @@ master_doc = 'index'
# General information about the project.
project = 'LVGL'
copyright = '2020, LVGL LLC'
author = 'The community of LVGL'
author = 'LVGL community'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -169,8 +169,6 @@ latex_elements = {
'preamble': r'''
\usepackage{fontspec}
\setmonofont{DejaVu Sans Mono}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}
\usepackage{silence}
\WarningsOff*
''',
@ -181,7 +179,7 @@ latex_elements = {
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'LVGL.tex', 'LVGL Documentation ' + version,
'Contributors of LVGL', 'manual'),
'LVGL community', 'manual'),
]
@ -230,28 +228,3 @@ def setup(app):
app.add_transform(AutoStructify)
app.add_stylesheet('css/custom.css')
app.add_stylesheet('css/fontawesome.min.css')
# Attempt to checkout _static/built_lv_examples
"""
if not os.path.exists('_static/built_lv_examples'):
os.system('git clone https://github.com/lvgl/lv_examples.git _static/built_lv_examples')
os.system('git -C _static/built_lv_examples fetch origin')
out = subprocess.Popen(["git", "-C", "lv_examples", "rev-parse", "HEAD"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout,stderr = out.communicate()
example_commit_hash = stdout.decode("utf-8").strip()
search_command = ["git", "-C", "_static/built_lv_examples", "--no-pager", "log", "--pretty=format:'%H'", "--all", "-n", "1", f"--grep='Deploying to gh-pages from @ {example_commit_hash}'"]
log_output = subprocess.check_output(' '.join(search_command), shell=True).strip().decode("utf-8")
if len(log_output) == 0:
raise ValueError('lv_examples: cannot find corresponding deployed commit: ' + example_commit_hash)
built_example_commit_hash = log_output
os.system('git -C _static/built_lv_examples reset --hard')
os.system('git -C _static/built_lv_examples checkout ' + log_output)
"""

View File

@ -3,6 +3,11 @@
:github_url: |github_link_base|/index.md
```
```eval_rst
PDF version: :download:`LVGL.pdf <LVGL.pdf>`
```
# Welcome to the documentation of LVGL!
<img src="_static/img/home_banner.jpg" style="width:100%">

View File

@ -4,13 +4,13 @@ C
Simple Arc
""""""""""""""""
.. lv_example:: widgets/arc/lv_arc_example_1
.. lv_example:: widgets/arc/lv_example_arc_1
:language: c
Loader with Arc
""""""""""""""""
.. lv_example:: widgets/arc/lv_arc_example_2
.. lv_example:: widgets/arc/lv_example_arc_2
:language: c
MicroPython