From 25acaf45ca87271106b23b52d0d941228e117859 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 14 Jun 2021 23:13:22 +0200 Subject: [PATCH] docs list all examples on one page --- docs/build.py | 5 + docs/example_list.py | 122 ++++++++++ docs/examples.md | 351 ++++++++++++++++++++++++++++ docs/header.rst | 2 +- docs/index.md | 1 + examples/widgets/keyboard/index.rst | 2 +- 6 files changed, 481 insertions(+), 2 deletions(-) create mode 100755 docs/example_list.py create mode 100644 docs/examples.md diff --git a/docs/build.py b/docs/build.py index 31fc3dc74..665b66eb3 100755 --- a/docs/build.py +++ b/docs/build.py @@ -4,6 +4,7 @@ import sys import os import subprocess import re +import example_list as ex langs = ['en'] @@ -25,6 +26,10 @@ def cmd(s): status, br = subprocess.getstatusoutput("git branch | grep '*'") _, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD") br = re.sub('\* ', '', br) + +# Generate the list of examples +ex.exec() + urlpath = re.sub('release/', '', br) # Be sure the github links point to the right branch diff --git a/docs/example_list.py b/docs/example_list.py new file mode 100755 index 000000000..b11acf4d7 --- /dev/null +++ b/docs/example_list.py @@ -0,0 +1,122 @@ +import os + +path ="../examples/" + +def process_index_rst(path): +# print(path) + with open(path) as fp: + last_line="" + line="" + title_tmp="" + line = fp.readline() + d = {} + while line: + if line[0:3] == '"""': + title_tmp = last_line + elif line[0:15] ==".. lv_example::": + name = line[16:].strip() + title_tmp = title_tmp.strip() + d[name] = title_tmp + last_line = line + line = fp.readline() + + return(d) + + +filelist = [] +for root, dirs, files in os.walk(path): + for f in files: + #append the file name to the list + filelist.append(os.path.join(root,f)) + +filelist = [ fi for fi in filelist if fi.endswith("index.rst") ] + +d_all = {} +#print all the file names +for fn in filelist: + d_act = process_index_rst(fn) + d_all.update(d_act) + +h1= { + "get_started":"Get started", + "styles":"Styles", + "anim":"Animations", + "event":"Events", + "layouts":"Layouts", + "scroll":"Scrolling", + "widgets":"Widgets" +} + +widgets = { +"obj":"Base object", +"arc":"Arc", +"bar":"Bar", +"btn":"Button","btnmatrix" +"calendar":"Calendar", +"canvas":"Canvas", +"chart":"Chart", +"checkbox":"Checkbox", +"colorwheel":"Colorwheel", +"dropdown":"Dropdown", +"img":"Image", +"imgbtn":"Image button", +"keyboard":"Keyboard", +"label":"Label", +"led":"LED", +"line":"Line", +"list":"List", +"meter":"Meter", +"msgbox":"Message box", +"roller":"Roller", +"slider":"Slider", +"span":"Span", +"spinbox":"Spinbox", +"spinner":"Spinner", +"switch":"Switch", +"table":"Table", +"tabview":"Tabview", +"textarea":"Textarea", +"tileview":"Tabview", +"win":"Window", +} + +layouts = { +"flex":"Flex", +"grid":"Grid", +} + +fout = open("examples.md", "w") + +def print_item(path, lvl): + for k in d_all: + v = d_all[k] + b = os.path.basename(k) + if k.startswith(path + "/lv_example_"): + fout.write("#"*lvl + " " + v + "\n") + fout.write('\n') + fout.write("\n") + +def exec(): + fout.write("```eval_rst\n") + fout.write(".. include:: /header.rst\n") + fout.write(":github_url: |github_link_base|/examples.md\n") + fout.write("```\n") + fout.write("\n") + fout.write("# Examples\n") + + for h in h1: + fout.write("## " + h1[h] + "\n") + + if h == "widgets": + for w in widgets: + fout.write("### " + widgets[w] + "\n") + print_item(h + "/" + w, 4) + elif h == "layouts": + for l in layouts: + fout.write("### " + layouts[l] + "\n") + print_item(h + "/" + l, 4) + else: + print_item(h, 3) + + fout.write("") + diff --git a/docs/examples.md b/docs/examples.md new file mode 100644 index 000000000..235ecab60 --- /dev/null +++ b/docs/examples.md @@ -0,0 +1,351 @@ +```eval_rst +.. include:: /header.rst +:github_url: |github_link_base|/examples.md +``` + +# Examples +## Get started +### A button with a label and react on click event + + +### Create styles from scratch for buttons + + +### Create a slider and write its value on a label + + +## Styles +### Size styles + + +### Background styles + + +### Border styles + + +### Outline styles + + +### Shadow styles + + +### Image styles + + +### Text styles + + +### Line styles + + +### Transition + + +### Using multiple styles + + +### Local styles + + +### Add styles to parts and states + + +### Extending the current theme + + +## Animations +### Start animation on an event + + +### Playback animation + + +## Events +### Button click event + + +### Handle multiple events + + +### Event bubbling + + +## Layouts +### Flex +#### A simple row and a column layout with flexbox + + +#### Arrange items in rows with wrap and even spacing + + +#### Demonstrate flex grow + + +#### Demonstrate flex grow. + + +#### Demonstrate column and row gap style properties + + +#### RTL base direction changes order of the items + + +### Grid +#### A simple grid + + +#### Demonstrate cell placement and span + + +#### Demonstrate grid's "free unit" + + +#### Demonstrate track placement + + +#### Demonstrate column and row gap + + +#### Demonstrate RTL direction on grid + + +## Scrolling +### Nested scrolling + + +### Snapping + + +### Floating button + + +### Styling the scrollbars + + +### Right to left scrolling + + +### Translate on scroll + + +## Widgets +### Base object +#### Base objects with custom styles + + +#### Make an object draggable + + +### Arc +#### Simple Arc + + +#### Loader with Arc + + +### Bar +#### Simple Bar + + +#### Styling a bar + + +#### Temperature meter + + +#### Stripe pattern and range value + + +#### Bar with RTL and RTL base direction + + +#### Custom drawr to show the current value + + +### Button +#### Simple Buttons + + +#### Styling buttons + + +#### Gummy button + + +### Calendar +### Canvas +#### Drawing on the Canvas and rotate + + +#### Transparent Canvas with chroma keying + + +### Chart +#### Line Chart + + +#### Faded area line chart with custom division lines + + +#### Axis ticks and labels with scrolling + + +#### Show the value of the pressed points + + +#### Display 1000 data points with zooming and scrolling + + +#### Show cursor on the clicked point + + +#### Scatter chart + + +### Checkbox +#### Simple Checkboxes + + +### Colorwheel +#### Simple Colorwheel + + +### Dropdown +#### Simple Drop down list + + +#### Drop down in four directions + + +#### Menu + + +### Image +#### Image from variable and symbol + + +#### Image recoloring + + +#### Rotate and zoom + + +#### Image offset and styling + + +### Image button +#### Simple Image button + + +### Keyboard +#### Keyboard with text area + + +### Label +#### Line wrap, recoloring and scrolling + + +#### Text shadow + + +#### Show LTR, RTL and Chinese texts + + +### LED +#### LED with custom style + + +### Line +#### Simple Line + + +### List +#### Simple List + + +### Meter +#### Simple meter + + +#### A meter with multiple arcs + + +#### A clock from a meter + + +#### Pie chart + + +### Message box +#### Simple Message box + + +### Roller +#### Simple Roller + + +#### Styling the roller + + +#### add fade mask to roller + + +### Slider +#### Simple Slider + + +#### Slider with custom style + + +#### Slider with extended drawer + + +### Span +#### Span with custom styles + + +### Spinbox +#### Simple Spinbox + + +### Spinner +#### Simple spinner + + +### Switch +#### Simple Switch + + +### Table +#### Simple table + + +#### Lightweighted list from table + + +### Tabview +#### Simple Tabview + + +#### Tabs on the left, styling and no scrolling + + +### Textarea +#### Simple Text area + + +#### Text area with password field + + +#### Text auto-formatting + + +### Tabview +#### Tileview with content + + +### Window +#### Simple window + + diff --git a/docs/header.rst b/docs/header.rst index fc4dc7d15..6ed996a69 100644 --- a/docs/header.rst +++ b/docs/header.rst @@ -1 +1 @@ -.. |github_link_base| replace:: https://github.com/lvgl/docs/blob/master \ No newline at end of file +.. |github_link_base| replace:: https://github.com/lvgl/lvgl/blob/8691611de2206669cd22e3e97c844fdf2bf494b0/docs \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index cca40368a..5e4be2f44 100644 --- a/docs/index.md +++ b/docs/index.md @@ -28,6 +28,7 @@ PDF version: :download:`LVGL.pdf ` :maxdepth: 2 intro/index + examples get-started/index porting/index overview/index diff --git a/examples/widgets/keyboard/index.rst b/examples/widgets/keyboard/index.rst index a99683171..7693623dd 100644 --- a/examples/widgets/keyboard/index.rst +++ b/examples/widgets/keyboard/index.rst @@ -2,6 +2,6 @@ Keyboard with text area """"""""""""""""""""""" -.. lv_example:: _widgets/keyboard/lv_example_keyboard_1 +.. lv_example:: widgets/keyboard/lv_example_keyboard_1 :language: c