Skip to content

Commit 01e8265

Browse files
committed
update doc generation
* Makefile: update to handle anchor link * doc/arduino.css: minor updates to styles * doc/mkfuncdocs.py, doc/mkqhcp.py: latest doc gen
1 parent a2b73a1 commit 01e8265

File tree

4 files changed

+95
-15
lines changed

4 files changed

+95
-15
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GREP ?= grep
1818
TAR ?= tar
1919
TEXI2PDF ?= texi2pdf -q
2020
MAKEINFO ?= makeinfo
21+
MAKEINFO_HTML_OPTIONS := --no-headers --set-customization-variable 'COPIABLE_LINKS 0' --set-customization-variable 'COPIABLE_ANCHORS 0' --no-split
2122
CUT ?= cut
2223
TR ?= tr
2324

@@ -159,7 +160,7 @@ doc/$(PACKAGE).pdf: doc/$(PACKAGE).texi doc/functions.texi doc/version.texi
159160
cd doc && $(RM) -f arduino.aux arduino.cp arduino.cps arduino.fn arduino.fns arduino.log arduino.toc
160161

161162
doc/$(PACKAGE).html: doc/$(PACKAGE).texi doc/functions.texi doc/version.texi
162-
cd doc && SOURCE_DATE_EPOCH=$(REPO_TIMESTAMP) $(MAKEINFO) --html --css-ref=$(PACKAGE).css --no-split --output=${PACKAGE}.html $(PACKAGE).texi
163+
cd doc && SOURCE_DATE_EPOCH=$(REPO_TIMESTAMP) $(MAKEINFO) --html --css-ref=$(PACKAGE).css $(MAKEINFO_HTML_OPTIONS) --output=${PACKAGE}.html $(PACKAGE).texi
163164

164165
doc/$(PACKAGE).qhc: doc/$(PACKAGE).html
165166
# try also create qch file if can

doc/arduino.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ pre.example {
88
background-color: #fdf6e3;
99
padding: 0.5em; }
1010

11-
table.cartouche {
11+
a { color: #268bd2; /* blue */ }
12+
13+
a:visited { color: #d33682; /* magenta */ }
14+
15+
table.cartouche1 {
1216
border: 1px solid #948473;
1317
background-color: #FFE3C6;
1418
width: 100%;
1519
}
16-
table.cartouche td, table.cartouche th {
20+
table.cartouche1 td, table.cartouche1 th {
1721
border: 1px solid #948473;
1822
padding: 4px 4px;
1923
}

doc/mkfuncdocs.py

+70-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python3
22

3-
## Copyright 2018-2023 John Donoghue
3+
## Copyright 2018-2024 John Donoghue
44
##
55
## This program is free software: you can redistribute it and/or modify it
66
## under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
1616
## along with this program. If not, see
1717
## <https://www.gnu.org/licenses/>.
1818

19-
## mkfuncdocs v1.0.7
19+
## mkfuncdocs v1.0.8
2020
## mkfuncdocs.py will attempt to extract the help texts from functions in src
2121
## dirs, extracting only those that are in the specifed INDEX file and output them
2222
## to stdout in texi format
@@ -89,6 +89,36 @@ def find_defun_line_in_file(filename, fnname):
8989

9090
return -1
9191

92+
def find_function_line_in_file(filename, fnname):
93+
linecnt = 0
94+
func = False
95+
defun_line=re.compile(r"^\s*function \s*")
96+
with open(filename, 'rt') as f:
97+
for line in f:
98+
if func == True:
99+
x = line.strip()
100+
if x.startswith("## -*- texinfo -*-"):
101+
return linecnt
102+
else:
103+
func = False
104+
105+
if re.match(defun_line, line):
106+
if line.find("=") != -1:
107+
x = line.split("=")
108+
x = x[-1]
109+
else:
110+
x = line.replace("function ", "")
111+
112+
x = x.split("(")
113+
x = x[0].strip()
114+
if x == fnname:
115+
func = True
116+
117+
linecnt = linecnt + 1
118+
119+
return -1
120+
121+
92122
def read_m_file(filename, skip=0):
93123
help = []
94124
inhelp = False
@@ -195,6 +225,29 @@ def read_index (filename, ignore):
195225

196226
return index;
197227

228+
def find_class_file(fname, paths):
229+
230+
for f in paths:
231+
# class constructor ?
232+
name = f + "/@" + fname + "/" + fname + ".m"
233+
if os.path.isfile(name):
234+
return name, 0
235+
236+
# perhaps classname.func format ?
237+
x = fname.split(".")
238+
if len(x) > 0:
239+
zname = x.pop()
240+
cname = ".".join(x)
241+
name = f + "/" + cname + ".m"
242+
if os.path.isfile(name):
243+
idx = find_function_line_in_file(name, zname)
244+
if idx >= 0:
245+
return name, idx
246+
name = f + "/@" + cname + "/" + zname + ".m"
247+
if os.path.isfile(name):
248+
return name, 0
249+
return None, -1
250+
198251
def find_func_file(fname, paths, prefix, scanfiles=False):
199252
for f in paths:
200253
name = f + "/" + fname + ".m"
@@ -205,7 +258,6 @@ def find_func_file(fname, paths, prefix, scanfiles=False):
205258
if os.path.isfile(name):
206259
return name, 0
207260
name = f + "/" + fname + ".cc"
208-
name = f + "/" + fname + ".cc"
209261
if os.path.isfile(name):
210262
return name, 0
211263
name = f + "/" + fname + ".cpp"
@@ -335,19 +387,26 @@ def process (args):
335387
ref = f.split("/")[-1]
336388
filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"])
337389
elif "." in f:
338-
parts = f.split('.')
339-
cnt = 0
340-
path = ""
341-
for p in parts:
390+
path = f
391+
ref = f.split(".")[-1]
392+
name = f.split(".")[-1]
393+
filename, lineno = find_class_file(path, options["srcdir"])
394+
395+
if not filename:
396+
parts = f.split('.')
397+
cnt = 0
398+
path = ""
399+
for p in parts:
342400
if cnt < len(parts)-1:
343401
path = path + "/+"
344402
else:
345403
path = path + "/"
346404
path = path + p
347405
cnt = cnt + 1
348-
name = f;
349-
ref = parts[-1]
350-
filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"])
406+
name = f;
407+
ref = parts[-1]
408+
filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"])
409+
351410
elif "/" in f:
352411
path = f
353412
name = f
@@ -360,7 +419,7 @@ def process (args):
360419
filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"], options['allowscan'])
361420

362421
if not filename:
363-
sys.stderr.write("Warning: Cant find source file for {}\n".format(path))
422+
sys.stderr.write("Warning: Cant find source file for {}\n".format(f))
364423
else:
365424
h = read_help (filename, lineno)
366425

doc/mkqhcp.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python3
22

33
## mkqhcp.py
4-
## Version 1.0.3
4+
## Version 1.0.4
55

66
## Copyright 2022-2023 John Donoghue
77
##
@@ -51,13 +51,21 @@ def process(name):
5151
title = e.group("title")
5252
break
5353

54+
# section
5455
h2_match = re.compile(r'.*<h2 class="chapter"[^>]*>(?P<title>[^<]+)</h2>.*')
56+
# appendix
57+
h2a_match = re.compile(r'.*<h2 class="appendix"[^>]*>(?P<title>[^<]+)</h2>.*')
58+
# index
59+
h2i_match = re.compile(r'.*<h2 class="unnumbered"[^>]*>(?P<title>[^<]+)</h2>.*')
60+
5561
h3_match = re.compile(r'.*<h3 class="section"[^>]*>(?P<title>[^<]+)</h3>.*')
5662
h4_match = re.compile(r'.*<h4 class="subsection"[^>]*>(?P<title>[^<]+)</h4>.*')
5763
tag_match1 = re.compile(r'.*<span id="(?P<tag>[^"]+)"[^>]*></span>.*')
5864
#tag_match2 = re.compile(r'.*<div class="[sub]*section" id="(?P<tag>[^"]+)"[^>]*>.*')
5965
tag_match2 = re.compile(r'.*<div class="[sub]*section[^"]*" id="(?P<tag>[^"]+)"[^>]*>.*')
6066
tag_match3 = re.compile(r'.*<div class="chapter-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*')
67+
tag_match4 = re.compile(r'.*<div class="appendix-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*')
68+
tag_match5 = re.compile(r'.*<div class="unnumbered-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*')
6169
index_match = re.compile(r'.*<h4 class="subsection"[^>]*>[\d\.\s]*(?P<name>[^<]+)</h4>.*')
6270

6371
tag = "top"
@@ -82,10 +90,18 @@ def process(name):
8290
e = tag_match2.match(line)
8391
if not e:
8492
e = tag_match3.match(line)
93+
if not e:
94+
e = tag_match4.match(line)
95+
if not e:
96+
e = tag_match5.match(line)
8597
if e:
8698
tag = e.group("tag")
8799

88100
e = h2_match.match(line)
101+
if not e:
102+
e = h2a_match.match(line)
103+
if not e:
104+
e = h2i_match.match(line)
89105
if e:
90106
if has_h3:
91107
f.write(' </section>\n')

0 commit comments

Comments
 (0)