Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
3793830e
Commit
3793830e
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
tools: Move gendoc.py to tools, and make it a little more generic.
parent
09bbe721
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/gendoc.py
+22
-7
22 additions, 7 deletions
tools/gendoc.py
with
22 additions
and
7 deletions
stmhal
/gendoc.py
→
tools
/gendoc.py
+
22
−
7
View file @
3793830e
...
...
@@ -67,6 +67,9 @@ class Lexer:
print
(
'
({}:{}) {}
'
.
format
(
self
.
filename
,
self
.
cur_line
,
msg
))
raise
Lexer
.
LexerError
class
DocValidateError
(
Exception
):
pass
class
DocItem
:
def
__init__
(
self
):
self
.
doc
=
[]
...
...
@@ -216,6 +219,10 @@ class DocModule(DocItem):
def
process_constant
(
self
,
lex
,
d
):
self
.
cur_class
.
process_constant
(
lex
,
d
)
def
validate
(
self
):
if
self
.
descr
is
None
:
raise
DocValidateError
(
'
module {} referenced but never defined
'
.
format
(
self
.
name
))
def
dump
(
self
):
s
=
[]
s
.
append
(
'
# module {}
'
.
format
(
self
.
name
))
...
...
@@ -262,15 +269,18 @@ class Doc:
def
process_module
(
self
,
lex
,
d
):
name
=
d
[
'
id
'
]
if
name
in
self
.
modules
:
if
name
not
in
self
.
modules
:
self
.
modules
[
name
]
=
DocModule
(
name
,
None
)
self
.
cur_module
=
self
.
modules
[
name
]
if
self
.
cur_module
.
descr
is
not
None
:
lex
.
error
(
"
multiple definition of module
'
{}
'"
.
format
(
name
))
self
.
cur_module
=
self
.
modules
[
name
]
=
DocModule
(
name
,
d
[
'
descr
'
]
)
self
.
cur_module
.
descr
=
d
[
'
descr
'
]
self
.
cur_module
.
add_doc
(
lex
)
def
process_moduleref
(
self
,
lex
,
d
):
name
=
d
[
'
id
'
]
if
name
not
in
self
.
modules
:
lex
.
error
(
'
module {} referenced before definition
'
.
format
(
name
)
)
self
.
modules
[
name
]
=
DocModule
(
name
,
None
)
self
.
cur_module
=
self
.
modules
[
name
]
lex
.
opt_break
()
...
...
@@ -294,6 +304,10 @@ class Doc:
self
.
check_module
(
lex
)
self
.
cur_module
.
process_constant
(
lex
,
d
)
def
validate
(
self
):
for
m
in
self
.
modules
.
values
():
m
.
validate
()
def
write
(
self
,
dir
):
for
m
in
self
.
modules
.
values
():
mod_dir
=
os
.
path
.
join
(
dir
,
'
module
'
,
m
.
name
)
...
...
@@ -339,17 +353,18 @@ def process_file(file, doc):
def
main
():
cmd_parser
=
argparse
.
ArgumentParser
(
description
=
'
Generate documentation for pyboard API from C files.
'
)
cmd_parser
.
add_argument
(
'
--outdir
'
,
metavar
=
'
<output dir>
'
,
default
=
'
gendoc-out
'
,
help
=
'
ouput directory
'
)
cmd_parser
.
add_argument
(
'
files
'
,
nargs
=
'
*
'
,
help
=
'
input files
'
)
cmd_parser
.
add_argument
(
'
files
'
,
nargs
=
'
+
'
,
help
=
'
input files
'
)
args
=
cmd_parser
.
parse_args
()
if
len
(
args
.
files
)
==
0
:
args
.
files
=
[
'
modpyb.c
'
,
'
accel.c
'
,
'
adc.c
'
,
'
dac.c
'
,
'
extint.c
'
,
'
i2c.c
'
,
'
led.c
'
,
'
pin.c
'
,
'
rng.c
'
,
'
servo.c
'
,
'
spi.c
'
,
'
uart.c
'
,
'
usrsw.c
'
,
'
timer.c
'
,
'
rtc.c
'
]
doc
=
Doc
()
for
file
in
args
.
files
:
print
(
'
processing
'
,
file
)
if
not
process_file
(
file
,
doc
):
return
try
:
doc
.
validate
()
except
DocValidateError
as
e
:
print
(
e
)
doc
.
write
(
args
.
outdir
)
print
(
'
written to
'
,
args
.
outdir
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment