Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
50009e15
Commit
50009e15
authored
Apr 28, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved javadoc generation scripts
parent
b165997e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
10 deletions
+55
-10
gen_javadoc.py
modules/java/gen_javadoc.py
+51
-8
rst_parser.py
modules/java/rst_parser.py
+4
-2
No files found.
modules/java/gen_javadoc.py
View file @
50009e15
import
os
,
sys
,
re
,
string
,
glob
allmodules
=
[
"core"
,
"flann"
,
"imgproc"
,
"ml"
,
"highgui"
,
"video"
,
"features2d"
,
"calib3d"
,
"objdetect"
,
"legacy"
,
"contrib"
,
"gpu"
,
"androidcamera"
,
"haartraining"
,
"java"
,
"python"
,
"stitching"
,
"traincascade"
,
"ts"
,
"photo"
]
allmodules
=
[
"core"
,
"flann"
,
"imgproc"
,
"ml"
,
"highgui"
,
"video"
,
"features2d"
,
"calib3d"
,
"objdetect"
,
"legacy"
,
"contrib"
,
"gpu"
,
"androidcamera"
,
"haartraining"
,
"java"
,
"python"
,
"stitching"
,
"traincascade"
,
"ts"
,
"photo"
,
"videostab"
]
verbose
=
False
show_warnings
=
True
show_errors
=
True
...
...
@@ -67,14 +67,47 @@ class JavadocGenerator(object):
inf
.
close
()
outf
.
close
()
def
FinishParagraph
(
self
,
text
):
return
text
[:
-
1
]
+
"</p>
\n
"
def
ReformatForJavadoc
(
self
,
s
):
out
=
""
in_paragraph
=
False
in_list
=
False
for
term
in
s
.
split
(
"
\n
"
):
if
term
.
startswith
(
"*"
)
or
term
.
startswith
(
"#."
):
term
=
" "
+
term
in_list_item
=
False
if
term
.
startswith
(
"*"
):
in_list_item
=
True
if
in_paragraph
:
out
=
self
.
FinishParagraph
(
out
)
in_paragraph
=
False
if
not
in_list
:
out
+=
" * <ul>
\n
"
in_list
=
True
term
=
" <li>"
+
term
[
1
:]
if
term
.
startswith
(
"#."
):
in_list_item
=
True
if
in_paragraph
:
out
=
self
.
FinishParagraph
(
out
)
in_paragraph
=
False
if
not
in_list
:
out
+=
" * <ul>
\n
"
in_list
=
True
term
=
" <li>"
+
term
[
2
:]
if
not
term
:
if
in_paragraph
:
out
=
self
.
FinishParagraph
(
out
)
in_paragraph
=
False
out
+=
" *
\n
"
else
:
if
in_list
and
not
in_list_item
:
in_list
=
False
if
out
.
endswith
(
" *
\n
"
):
out
=
out
[:
-
3
]
+
" * </ul>
\n
*
\n
"
else
:
out
+=
" * </ul>
\n
"
pos_start
=
0
pos_end
=
min
(
77
,
len
(
term
)
-
1
)
while
pos_start
<
pos_end
:
...
...
@@ -91,12 +124,22 @@ class JavadocGenerator(object):
pos_end
+=
1
else
:
break
out
+=
" * "
+
term
[
pos_start
:
pos_end
+
1
]
.
rstrip
()
+
"
\n
"
if
in_paragraph
or
term
.
startswith
(
"@"
)
or
in_list_item
:
out
+=
" * "
else
:
in_paragraph
=
True
out
+=
" * <p>"
out
+=
term
[
pos_start
:
pos_end
+
1
]
.
rstrip
()
+
"
\n
"
pos_start
=
pos_end
+
1
pos_end
=
min
(
pos_start
+
77
,
len
(
term
)
-
1
)
if
in_paragraph
:
out
=
self
.
FinishParagraph
(
out
)
if
in_list
:
out
+=
" * </ul>
\n
"
return
out
def
getJavaName
(
self
,
decl
):
def
getJavaName
(
self
,
decl
,
methodSeparator
=
"."
):
name
=
"org.opencv."
name
+=
decl
[
"module"
]
if
"class"
in
decl
:
...
...
@@ -104,11 +147,11 @@ class JavadocGenerator(object):
else
:
name
+=
"."
+
decl
[
"module"
]
.
capitalize
()
if
"method"
in
decl
:
name
+=
"."
+
decl
[
"method"
]
name
+=
methodSeparator
+
decl
[
"method"
]
return
name
def
getDocURL
(
self
,
decl
):
url
=
"http://
opencv.itseez.com
/modules/"
url
=
"http://
docs.opencv.org
/modules/"
url
+=
decl
[
"module"
]
url
+=
"/doc/"
url
+=
os
.
path
.
basename
(
decl
[
"file"
])
.
replace
(
".rst"
,
".html"
)
...
...
@@ -168,7 +211,7 @@ class JavadocGenerator(object):
for
see
in
decl
[
"seealso"
]:
seedecl
=
self
.
definitions
.
get
(
see
,
None
)
if
seedecl
:
doc
+=
prefix
+
" * @see "
+
self
.
getJavaName
(
seedecl
)
+
"
\n
"
doc
+=
prefix
+
" * @see "
+
self
.
getJavaName
(
seedecl
,
"#"
)
+
"
\n
"
else
:
doc
+=
prefix
+
" * @see "
+
see
.
replace
(
"::"
,
"."
)
+
"
\n
"
prefix
=
" *
\n
"
...
...
modules/java/rst_parser.py
View file @
50009e15
...
...
@@ -499,7 +499,8 @@ class RstParser(object):
def
normalizeText
(
self
,
s
):
if
s
is
None
:
return
s
s
=
re
.
sub
(
r"\.\. math::[ ]*\n+(.*?)(\n[ ]*\n|$)"
,
mathReplace2
,
s
)
s
=
re
.
sub
(
r"\.\. math::[ \r]*\n+((.|\n)*?)(\n[ \r]*\n|$)"
,
mathReplace2
,
s
)
s
=
re
.
sub
(
r":math:`([^`]+?)`"
,
mathReplace
,
s
)
s
=
re
.
sub
(
r" *:sup:"
,
"^"
,
s
)
...
...
@@ -574,6 +575,7 @@ class RstParser(object):
s
=
re
.
sub
(
r"[\n ]+\."
,
"."
,
s
)
s
=
s
.
replace
(
"**"
,
""
)
s
=
re
.
sub
(
r"``([^\n]+?)``"
,
"<code>
\\
1</code>"
,
s
)
s
=
s
.
replace
(
"``"
,
"
\"
"
)
s
=
s
.
replace
(
"`"
,
"
\"
"
)
s
=
s
.
replace
(
"
\"\"
"
,
"
\"
"
)
...
...
@@ -688,7 +690,7 @@ def mathReplace(match):
m
=
m
.
replace
(
"}"
,
")"
)
#print "%s ===> %s" % (match.group(0), m)
return
m
return
"<em>"
+
m
+
"</em>"
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
<
2
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment