Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LcdMenu 5.0.0 Documentation #230

Merged
merged 74 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2ab3221
Add Doxygen and Sphinx documentation workflows
forntoh Sep 25, 2024
a2af300
Update permissions for generating and deploying documentation.
forntoh Sep 25, 2024
065e36b
Update permissions in workflow file
forntoh Sep 25, 2024
6dc7c30
update
forntoh Sep 25, 2024
4b9002e
fix workflow
forntoh Sep 25, 2024
01817b3
fix name
forntoh Sep 25, 2024
a142ad9
updates
forntoh Sep 26, 2024
60e881e
fix script
forntoh Sep 26, 2024
506cc26
doc update
forntoh Sep 26, 2024
6866ef1
Update docs
forntoh Sep 26, 2024
0f8f01d
Update workflow
forntoh Sep 27, 2024
58f31e6
update requirements
forntoh Sep 27, 2024
e4a3315
update docs
forntoh Sep 28, 2024
1fa2253
update docs
forntoh Sep 28, 2024
d7529c7
Update menu item names to capitalize first letters and add new toggle…
forntoh Sep 29, 2024
db7eef7
Update grid layout and add license information
forntoh Sep 29, 2024
bc37cd2
Update examples and link to docs
forntoh Sep 29, 2024
77d64be
Update index
forntoh Sep 29, 2024
0527e44
Merge branch 'feature/move-control-to-items' into feature/new-docs
forntoh Sep 29, 2024
e502edb
Merge branch 'feature/move-control-to-items' into feature/new-docs
forntoh Sep 29, 2024
138bf01
Update workflow to trigger on specific paths, adjust Python version s…
forntoh Sep 29, 2024
ad622ae
Merge branch 'feature/move-control-to-items' into feature/new-docs
forntoh Sep 29, 2024
8568014
Use smaller images
forntoh Sep 29, 2024
6aca595
Add custom CSS file and new HTML template for badges
forntoh Sep 29, 2024
b6e76be
add logo
forntoh Sep 30, 2024
d17c100
add submenu docs
forntoh Sep 30, 2024
583dc9a
add list docs
forntoh Sep 30, 2024
5e9cb35
added item range docs
forntoh Sep 30, 2024
7f43884
correct docs
forntoh Sep 30, 2024
f5a7238
add item input
forntoh Sep 30, 2024
8181e21
add charset docs
forntoh Sep 30, 2024
0d031bb
move to different folder
forntoh Sep 30, 2024
df2d048
add star on github
forntoh Oct 1, 2024
f809630
add controls docs
forntoh Oct 1, 2024
a769232
Rename and update GitHub badge templates, remove old edit on GitHub t…
forntoh Oct 1, 2024
1311d42
Update GitHub badges layout and spacing in HTML template.
forntoh Oct 1, 2024
60194c1
Update directory name to "Code samples" in create_index_file function
forntoh Oct 1, 2024
64dc20d
Update index references and fix capitalization in class diagram heading
forntoh Oct 1, 2024
9c83edc
add changeloh to nav
forntoh Oct 1, 2024
b558038
Add "License" to main navigation links and remove license reference f…
forntoh Oct 1, 2024
59f920d
Update menu structure and add FAQs section with common questions and …
forntoh Oct 1, 2024
2cb7f68
update faq
forntoh Oct 1, 2024
96feca9
update readme.md
forntoh Oct 1, 2024
d22615c
update readme
forntoh Oct 1, 2024
3103e5b
Update README formatting for LcdMenu project.
forntoh Oct 1, 2024
32967ff
Update asset
forntoh Oct 1, 2024
0c46dde
try update readme
forntoh Oct 1, 2024
5b2850a
update logos
forntoh Oct 1, 2024
f52c17a
Update README.md
forntoh Oct 1, 2024
89e6589
Update README.md
forntoh Oct 1, 2024
107625b
clang fix
forntoh Oct 1, 2024
e240c53
Merge branch 'feature/new-docs' of https://github.com/forntoh/LcdMenu…
forntoh Oct 1, 2024
a7d8ba6
spell check fix
forntoh Oct 1, 2024
024b344
Update link to official documentation in README.md
forntoh Oct 1, 2024
e3c32d8
Add documentation build instructions and custom script details
forntoh Oct 1, 2024
4e55589
Update README.md
forntoh Oct 1, 2024
18c277e
Update docs readme
forntoh Oct 1, 2024
f20d8d9
Add shell scripts in PIO ignore list
forntoh Oct 1, 2024
a0148b5
Update script calls to use Python 3.
forntoh Oct 1, 2024
98c93fe
Update documentation build process and configuration
forntoh Oct 1, 2024
d271762
Add installation command for Doxygen in README
forntoh Oct 1, 2024
0176930
Add pre-build dependencies installation in readthedocs.yml
forntoh Oct 1, 2024
e27acfc
Update build commands for better compatibility and efficiency.
forntoh Oct 1, 2024
47709c7
try post install
forntoh Oct 1, 2024
76fd0b8
Update readthedocs.yml for sudo in apt-get commands
forntoh Oct 1, 2024
f3cf1b0
Update pre-build system dependencies
forntoh Oct 1, 2024
9e8fb76
Add doxygen, graphviz, default-jre, plantuml as apt packages
forntoh Oct 1, 2024
9695756
Updated migration guide
forntoh Oct 3, 2024
2d04a6f
Spell check fix
forntoh Oct 3, 2024
e801098
Update images
forntoh Oct 3, 2024
3d0a598
Update README.md with centered image for menu system example.
forntoh Oct 3, 2024
f7a43ed
Add branch restriction for master in workflow file
forntoh Oct 3, 2024
dbed352
Merge branch 'feature/move-control-to-items' into feature/new-docs
forntoh Oct 4, 2024
f2c3a69
Change favicon
forntoh Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Deploy Docs

on:
push:
branches:
- master
paths:
- "src/**"
- "docs/**"
- "examples/**"
- ".scripts/**"
- ".github/workflows/docs.yml"

permissions:
contents: write
pages: write
id-token: write

jobs:
build-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
sudo apt-get update
sudo apt-get install -y doxygen graphviz default-jre plantuml

- name: Pre-build
run: |
chmod +x docs/pre_build.bat
docs/pre_build.bat

- name: Generate Sphinx documentation
run: make html
working-directory: docs
env:
GITHUB_ACTIONS: true

- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ _site/
.jekyll-cache/
.arduino_ci/
*.tar.gz
*.lock
*.lock
_build/
docs/doxygen/
docs/source/reference/api
30 changes: 30 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- doxygen
- graphviz
- default-jre
- plantuml
jobs:
pre_build:
- chmod +x docs/pre_build.bat
- docs/pre_build.bat

sphinx:
configuration: docs/source/conf.py

formats:
- pdf
- epub

python:
install:
- requirements: docs/requirements.txt
56 changes: 56 additions & 0 deletions .scripts/append_includes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import re
import sys


def replace_includes(directory, sort_order='asc', use_toctree=False):
include_pattern = re.compile(r'\.\. include::\s+\S+')
toctree_pattern = re.compile(r'\.\. toctree::\s+.*?(\n\s+.*?)*', re.DOTALL)
maxdepth_pattern = re.compile(r':maxdepth:\s+\d+')
rst_file_pattern = re.compile(r'^\s+\S+\.rst$', re.MULTILINE)

for root, _, files in os.walk(directory):
if 'index.rst' in files:
index_path = os.path.join(root, 'index.rst')
print(f"Processing {index_path}")
with open(index_path, 'r') as index_file:
content = index_file.read()

# Remove existing include, toctree, maxdepth, and rst file directives
content = include_pattern.sub('', content)
content = toctree_pattern.sub('', content)
content = maxdepth_pattern.sub('', content)
content = rst_file_pattern.sub('', content).strip()

rst_files = [file for file in files if file.endswith('.rst') and file != 'index.rst']
rst_files.sort(reverse=(sort_order == 'desc'))

if use_toctree:
content += '\n\n.. toctree::\n :maxdepth: 2\n\n'
for file in rst_files:
content += f' {file}\n'
print(f"Added {file} to toctree")
else:
content += '\n'
for file in rst_files:
content += f'\n.. include:: {file}'
print(f"Added include directive for {file}")

with open(index_path, 'w') as index_file:
index_file.write(content.strip() + '\n')
print(f"Updated {index_path}")

if __name__ == "__main__":
if len(sys.argv) < 2 or len(sys.argv) > 4:
print("Usage: python append_includes.py <directory_path> [sort_order] [use_toctree]")
sys.exit(1)

directory_path = sys.argv[1]
sort_order = sys.argv[2] if len(sys.argv) >= 3 else 'asc'
use_toctree = sys.argv[3].lower() == 'true' if len(sys.argv) == 4 else False

if sort_order not in ['asc', 'desc']:
print("Invalid sort order. Use 'asc' for ascending or 'desc' for descending.")
sys.exit(1)

replace_includes(directory_path, sort_order, use_toctree)
8 changes: 4 additions & 4 deletions .scripts/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def build(files):
if re.search(r"^.+\s[a-z][A-Za-z]+\(.*", stripped_line) != None:
words = re.findall(r"\w+", stripped_line)
methodName = words[1]
if words[0] == 'const':
if words[0] == 'const' or words[0] == 'inline':
methodName = words[2]
keyword_2_data.add(methodName + " KEYWORD2\n")
if len(stripped_line) > 7 and stripped_line.startswith('class '):
Expand All @@ -61,11 +61,11 @@ def build(files):
with open("keywords.txt", "w") as a_file:
a_file.truncate()
a_file.write(pre_key_1)
a_file.writelines(keyword_1_data)
a_file.writelines(sorted(keyword_1_data))
a_file.write(pre_key_2)
a_file.writelines(keyword_2_data)
a_file.writelines(sorted(keyword_2_data))
a_file.write(pre_lit_1)
a_file.writelines(literal_1_data)
a_file.writelines(sorted(literal_1_data))
print("Updated keywords")

if __name__ == '__main__':
Expand Down
57 changes: 57 additions & 0 deletions .scripts/link_doxygen_sphinx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os

src_dir = 'src'
dest_dir = 'docs/source/reference/api'
skip_files = []
skip_dirs = ['utils']

def create_rst_file(src_path, dest_path):
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
filename = os.path.basename(src_path).replace('.h', '')
with open(dest_path, 'w') as rst_file:
rst_file.write(f'{filename}\n')
rst_file.write(f'{"=" * len(filename)}\n\n')
rst_file.write(f'.. doxygenfile:: {filename}.h\n')
rst_file.write(f' :project: LcdMenu\n')

def create_index_file(directory, entries, subdirs, is_root=False):
dir_name = os.path.basename(directory) if not is_root else "API reference"
index_path = os.path.join(directory, 'index.rst')
with open(index_path, 'w') as index_file:
index_file.write(f'{dir_name}\n')
index_file.write(f'{"=" * len(dir_name)}\n\n')
if is_root:
index_file.write('.. rst-class:: lead\n\n')
index_file.write('This section contains the API reference documentation for the |project| library.\n')
index_file.write('Here you will find detailed descriptions of all the classes, their methods, and attributes.\n\n')
index_file.write('-'*80)
index_file.write('\n\n')
index_file.write('.. toctree::\n')
index_file.write(' :maxdepth: 1\n')
index_file.write(f' :caption: {dir_name}\n\n')
for entry in entries:
relative_entry = os.path.relpath(entry, directory).replace('.rst', '')
index_file.write(f' {relative_entry}\n')
for subdir in subdirs:
relative_subdir = os.path.basename(subdir)
index_file.write(f' {relative_subdir}/index\n')

def process_directory(directory, skip_files, skip_dirs, is_root=False):
for root, dirs, files in os.walk(directory):
dirs[:] = [d for d in dirs if d not in skip_dirs]

index_entries = []
subdirs = [os.path.join(root, d) for d in dirs]
for file in files:
if file.endswith('.h') and file not in skip_files:
src_path = os.path.relpath(os.path.join(root, file), src_dir)
dest_path = os.path.join(dest_dir, src_path).replace('.h', '.rst')
create_rst_file(src_path, dest_path)
index_entries.append(dest_path)

if index_entries or subdirs:
create_index_file(os.path.join(dest_dir, os.path.relpath(root, src_dir)), index_entries, subdirs, is_root)
is_root = False

if __name__ == '__main__':
process_directory(src_dir, skip_files, skip_dirs, is_root=True)
57 changes: 57 additions & 0 deletions .scripts/link_examples_sphinx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os

src_dir = 'examples'
dest_dir = 'docs/source/reference/samples'
skip_files = []
skip_dirs = []

def create_rst_file(src_path, dest_path):
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
filename = os.path.basename(src_path).replace('.ino', '')
with open(dest_path, 'w') as rst_file:
rst_file.write(f'{filename}\n')
rst_file.write(f'{"=" * len(filename)}\n\n')
rst_file.write(f'.. literalinclude:: ../../../../{src_dir}/{src_path}\n')
rst_file.write(f' :language: cpp\n')
rst_file.write(f' :linenos:\n\n')

def create_index_file(directory, entries):
dir_name = "Code samples"
index_path = os.path.join(directory, 'index.rst')
os.makedirs(os.path.dirname(index_path), exist_ok=True)
with open(index_path, 'w') as index_file:
index_file.write(f'{dir_name}\n')
index_file.write(f'{"=" * len(dir_name)}\n\n')
index_file.write('.. rst-class:: lead\n\n')
index_file.write('This section contains code samples that demonstrate how to use the |project| library.\n')
index_file.write('Each sample is a complete program that shows how to use the library to accomplish a specific task.\n')
index_file.write('You can find the source code for each sample in the `examples <https://github.com/forntoh/LcdMenu/tree/master/examples>`_ directory of the library repository.\n\n')
index_file.write('-'*80)
index_file.write('\n\n')
index_file.write('.. toctree::\n')
index_file.write(' :maxdepth: 1\n')
index_file.write(f' :caption: {dir_name}\n\n')
for entry in entries:
print(entry)
relative_entry = os.path.relpath(entry, directory).replace('.rst', '')
index_file.write(f' {relative_entry}\n')

def process_directory(directory, skip_files, skip_dirs):
index_entries = []

for root, dirs, files in os.walk(directory):
dirs[:] = [d for d in dirs if d not in skip_dirs]

for file in files:
if file.endswith('.ino') and file not in skip_files:
src_path = os.path.relpath(os.path.join(root, file), src_dir)
dest_path = os.path.join(dest_dir, os.path.basename(file)).replace('.ino', '.rst')
create_rst_file(src_path, dest_path)
print(f'Created {dest_path}')
index_entries.append(dest_path)

if index_entries:
create_index_file(dest_dir, index_entries)

if __name__ == '__main__':
process_directory(src_dir, skip_files, skip_dirs)
56 changes: 56 additions & 0 deletions .scripts/update_changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import re

import requests

GITHUB_API_URL = "https://api.github.com/repos/{owner}/{repo}/releases"
OWNER = "forntoh"
REPO = "LcdMenu"
CHANGELOG_FILE = "docs/source/reference/changelog.rst"

def fetch_releases():
url = GITHUB_API_URL.format(owner=OWNER, repo=REPO)
response = requests.get(url)
response.raise_for_status()
return response.json()

def convert_md_to_rst(body):
lines = body.split('\n')
rst_lines = []
for line in lines:
if line.startswith('## '):
heading = line[3:]
rst_lines.append(heading)
rst_lines.append('~' * len(heading))
elif line.startswith('### '):
heading = line[4:]
rst_lines.append(heading)
rst_lines.append('+' * len(heading))
else:
line = re.sub(r'(https://github\.com/forntoh/LcdMenu/pull/(\d+))', r'`#\2 <\1>`_', line)
rst_lines.append(line)
return '\n'.join(rst_lines)

def format_release(release):
body = convert_md_to_rst(release['body'])
return f"{release['name']}\n{'-' * len(release['name'])}\n\n{body}\n"


def update_changelog(releases):
with open(CHANGELOG_FILE, 'r') as file:
lines = file.readlines()

with open(CHANGELOG_FILE, 'w') as file:
for line in lines:
if line.strip() == "----------------":
break
file.write(line)

file.write("\n")
for release in releases:
file.write(format_release(release))
print(f"Added release: {release['name']}")
file.write("\n")

if __name__ == "__main__":
releases = fetch_releases()
update_changelog(releases)
7 changes: 6 additions & 1 deletion .scripts/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ def build(files, version):
data = ''
separator = ''
if file.endswith('.json'): separator = ": "
elif file.endswith('.rst'): separator = '^'
else: separator = '='

with open(file, "r") as a_file:
for line in a_file:
stripped_line = line.strip()
key = stripped_line.split(separator, 1)[0]

if re.search("version", key) != None:

if separator == '^' and re.search("forntoh/LcdMenu", key) != None:
spaces = len(line) - len(line.lstrip())
data+=(' ' * spaces + key + separator + version + '\n')
elif re.search("version", key) != None:
anchor = ''
suffix = ''
prefix = ''
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2023 Forntoh Thomas
Copyright (c) 2020-2024 Forntoh Thomas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading
Loading