Skip to content

Commit 8430756

Browse files
committed
Add Sphinx doc and helper scripts
Signed-off-by: Travis F. Collins <[email protected]>
1 parent 2667d3d commit 8430756

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3390
-0
lines changed

doc/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/doxygen/doxyfile.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
GENERATE_XML = YES
2+
INPUT = ../../include/iio
3+
OUTPUT_DIRECTORY = generated
4+
5+
ENABLE_PREPROCESSING = YES
6+
MACRO_EXPANSION = YES
7+
EXPAND_ONLY_PREDEF = YES
8+
PREDEFINED = "__api= " \
9+
"__check_ret= " \
10+
"__pure= " \
11+
"__cnst= "
12+
13+
GENERATE_HTML = NO
14+
GENERATE_LATEX = NO
15+
16+
EXCLUDE = ../../iio-private.h \
17+
../../debug.h \
18+
../../iio-lock.h \
19+
../../iiod-client.h \
20+
../../sort.h \
21+
../../network.h

doc/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

doc/man_to_rst.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Convert man pages to reStructuredText
2+
import os
3+
4+
manfolder = os.path.join(os.path.dirname(__file__), "..","build", "share","man")
5+
page = ['iio_attr','iio_info','iio_genxml','iio_rwdev','iio_reg','iio_stresstest']
6+
7+
tools = {}
8+
9+
for po in page:
10+
print(f"Converting {po} to reStructuredText")
11+
p = po + ".1"
12+
fullpath = os.path.join(manfolder, p)
13+
target = os.path.join("source", "tools", po + ".rst")
14+
os.system(f"pandoc --from man --to rst {fullpath} -o {target}")
15+
16+
# Add title to rst file
17+
with open(target, 'r') as file:
18+
data = file.readlines()
19+
20+
# Downgrade all headers by one level
21+
for i in range(len(data)):
22+
if data[i].startswith("="):
23+
data[i] = data[i].replace("=", "-")
24+
if data[i].startswith("#"):
25+
data[i] = data[i].replace("#", "=")
26+
27+
data.insert(0, f"{po}\n")
28+
data.insert(1, "=" * len(po) + "\n")
29+
30+
# Remove NAME line and the following line
31+
for i in range(len(data)):
32+
if data[i].startswith("NAME"):
33+
data.pop(i)
34+
data.pop(i)
35+
ref = data[i+1]
36+
print(f"Reference: {ref}")
37+
tool = ref.split("-")[0].strip()
38+
description = ref.split("-")[1].strip()
39+
tools[tool] = description
40+
break
41+
42+
with open(target, 'w') as file:
43+
file.writelines(data)
44+
45+
# Build index for cli tools
46+
print("Building index for cli tools")
47+
48+
index = os.path.join("source", "tools", "index.rst")
49+
50+
with open(index, 'w') as file:
51+
file.write("Command Line Tools\n")
52+
file.write("==================\n\n")
53+
file.write(".. toctree::\n")
54+
file.write(" :maxdepth: 1\n\n")
55+
for tool in tools:
56+
file.write(f" {tool}\n")
57+
file.write("\n\n")
58+

doc/requirements_doc.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sphinx
2+
https://github.com/analogdevicesinc/doctools/releases/download/latest/adi-doctools.tar.gz
3+
sphinxcontrib.wavedrom
4+
myst-parser
5+
breathe
6+
sphinx-inline-tabs
7+
sphinxcontrib-matlabdomain

doc/source/_static/codemodel.svg

Lines changed: 579 additions & 0 deletions
Loading
101 KB
Loading
259 KB
Loading
296 KB
Loading
215 KB
Loading

0 commit comments

Comments
 (0)