This commit is contained in:
Gabor Kiss-Vamosi
2021-06-08 14:11:31 +02:00
4 changed files with 15 additions and 8 deletions

View File

@@ -1,14 +1,17 @@
from docutils.parsers.rst import Directive import os
from docutils import nodes from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst.directives.images import Image from docutils.parsers.rst.directives.images import Image
from sphinx.directives.code import LiteralInclude from sphinx.directives.code import LiteralInclude
import os
class LvExample(Directive): class LvExample(Directive):
required_arguments = 3 required_arguments = 3
def run(self): def run(self):
example_path = self.arguments[0] example_path = self.arguments[0]
example_name = os.path.split(example_path)[1] example_name = os.path.split(example_path)[1]
language = self.arguments[2]
node_list = [] node_list = []
env = self.state.document.settings.env env = self.state.document.settings.env
@@ -28,9 +31,9 @@ class LvExample(Directive):
except FileNotFoundError: except FileNotFoundError:
contents = 'Error encountered while trying to open ' + example_file contents = 'Error encountered while trying to open ' + example_file
literal_list = nodes.literal_block(contents, contents) literal_list = nodes.literal_block(contents, contents)
literal_list['language'] = self.arguments[2] literal_list['language'] = language
toggle.append(literal_list) toggle.append(literal_list)
header.append(nodes.paragraph(text="code")) header.append(nodes.raw(text=f"<p>code &nbsp; <a class='fa fa-github' href='https://github.com/lvgl/lvgl/blob/{env.config.repo_commit_hash}/examples/{example_path}.{language}'>&nbsp; view on GitHub</a></p>", format='html'))
if env.app.tags.has('html'): if env.app.tags.has('html'):
node_list.append(paragraph_node) node_list.append(paragraph_node)
node_list.append(toggle) node_list.append(toggle)
@@ -38,8 +41,7 @@ class LvExample(Directive):
def setup(app): def setup(app):
app.add_directive("lv_example", LvExample) app.add_directive("lv_example", LvExample)
app.add_config_value("example_commit_hash", "", "env") app.add_config_value("repo_commit_hash", "", "env")
app.add_config_value("built_example_commit_hash", "", "env")
return { return {
'version': '0.1', 'version': '0.1',

View File

@@ -29,7 +29,9 @@ function add_version_selector()
p.innerHTML = ` p.innerHTML = `
<select name="versions" id="versions" onchange="ver_sel()" style="border-radius:5px; margin-bottom:15px"> <select name="versions" id="versions" onchange="ver_sel()" style="border-radius:5px; margin-bottom:15px">
${versions.map(version => { ${versions.map(version => {
const versionName = "v" + ((version.indexOf(".") != -1) ? version : (version + " (latest minor)")); let versionName = "";
if(version == "master") versionName = "master (latest)";
else versionName = "v" + ((version.indexOf(".") != -1) ? version : (version + " (latest minor)"));
return `<option value="${version}">${versionName}</option>`; return `<option value="${version}">${versionName}</option>`;
})} })}
</select>` + p.innerHTML; </select>` + p.innerHTML;

View File

@@ -224,6 +224,9 @@ StandaloneHTMLBuilder.supported_image_types = [
smartquotes = False smartquotes = False
_, repo_commit_hash = subprocess.getstatusoutput("git rev-parse HEAD")
# Example configuration for intersphinx: refer to the Python standard library. # Example configuration for intersphinx: refer to the Python standard library.
def setup(app): def setup(app):

View File

@@ -27,7 +27,7 @@
#define LV_COLOR_16_SWAP 0 #define LV_COLOR_16_SWAP 0
/*Enable more complex drawing routines to manage screens transparency. /*Enable more complex drawing routines to manage screens transparency.
*Can be used if the UI is above an other layer, e.g. an OSD menu or video player. *Can be used if the UI is above another layer, e.g. an OSD menu or video player.
*Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/
#define LV_COLOR_SCREEN_TRANSP 0 #define LV_COLOR_SCREEN_TRANSP 0