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
164a77e7
Commit
164a77e7
authored
Nov 19, 2017
by
tribta
Committed by
Alexander Alekhin
Dec 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add methods
parent
6174f627
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
51 deletions
+91
-51
add_signatures.py
doc/tools/add_signatures.py
+2
-2
html_functions.py
doc/tools/html_functions.py
+89
-49
No files found.
doc/tools/add_signatures.py
View file @
164a77e7
...
@@ -71,14 +71,14 @@ classes = root.findall("./compound[@kind='class']")
...
@@ -71,14 +71,14 @@ classes = root.findall("./compound[@kind='class']")
for
c
in
classes
:
for
c
in
classes
:
c_name
=
c
.
find
(
"./name"
)
.
text
c_name
=
c
.
find
(
"./name"
)
.
text
name
=
ns_name
+
'::'
+
c_name
name
=
ns_name
+
'::'
+
c_name
file
=
c
.
find
(
"./filename"
)
.
text
file
=
c
.
find
(
"./filename"
)
.
text
#print('Class: {} => {}'.format(name, file))
#print('Class: {} => {}'.format(name, file))
files_dict
=
doxygen_scan
.
scan_class_methods
(
c
,
c_name
,
files_dict
)
files_dict
=
doxygen_scan
.
scan_class_methods
(
c
,
c_name
,
files_dict
)
# test
# test
for
file
in
files_dict
:
for
file
in
files_dict
:
soup
=
html_functions
.
load_html_file
(
ROOT_DIR
+
file
)
soup
=
html_functions
.
load_html_file
(
ROOT_DIR
+
file
)
if
file
==
"d4/d86/group__imgproc__filter.html"
:
#"d4/d86/group__imgproc__filter.html":
if
file
==
"d
d/d9e/classcv_1_1VideoWriter.html"
:
#"d
4/d86/group__imgproc__filter.html":#"d4/d86/group__imgproc__filter.html":
anchor_list
=
files_dict
[
file
]
anchor_list
=
files_dict
[
file
]
counter
=
0
counter
=
0
anchor_tmp_list
=
[]
anchor_tmp_list
=
[]
...
...
doc/tools/html_functions.py
View file @
164a77e7
...
@@ -26,15 +26,20 @@ def add_item(soup, new_row, is_parameter, text):
...
@@ -26,15 +26,20 @@ def add_item(soup, new_row, is_parameter, text):
new_row
.
append
(
new_item
)
new_row
.
append
(
new_item
)
return
new_row
,
soup
return
new_row
,
soup
def
add_signature_to_table
(
soup
,
tmp_row
,
signature
,
language
):
def
add_signature_to_table
(
soup
,
tmp_row
,
signature
,
language
,
type
):
""" Add a signature to an html table"""
""" Add a signature to an html table"""
new_item
=
soup
.
new_tag
(
'td'
,
style
=
"padding-left: 0.5cm;"
)
new_item
=
soup
.
new_tag
(
'td'
,
style
=
"padding-left: 0.5cm;"
)
if
str
(
signature
.
get
(
'ret'
,
None
))
!=
"None"
:
if
str
(
signature
.
get
(
'ret'
,
None
))
!=
"None"
:
new_item
.
append
(
signature
.
get
(
'ret'
)
+
' ='
)
new_item
.
append
(
signature
.
get
(
'ret'
)
+
' ='
)
tmp_row
.
append
(
new_item
)
tmp_row
.
append
(
new_item
)
tmp_row
,
soup
=
add_item
(
soup
,
tmp_row
,
False
,
"cv2."
+
signature
.
get
(
'name'
,
None
)
+
'('
)
tmp_name
=
signature
.
get
(
'name'
,
None
)
if
type
is
not
"method"
:
tmp_name
=
"cv2."
+
tmp_name
else
:
tmp_name
=
"obj."
+
tmp_name
tmp_row
,
soup
=
add_item
(
soup
,
tmp_row
,
False
,
tmp_name
+
'('
)
tmp_row
,
soup
=
add_item
(
soup
,
tmp_row
,
True
,
signature
[
'arg'
])
tmp_row
,
soup
=
add_item
(
soup
,
tmp_row
,
True
,
signature
[
'arg'
])
tmp_row
,
soup
=
add_item
(
soup
,
tmp_row
,
False
,
')'
)
tmp_row
,
soup
=
add_item
(
soup
,
tmp_row
,
False
,
')'
)
return
tmp_row
,
soup
return
tmp_row
,
soup
...
@@ -55,7 +60,7 @@ def add_bolded(soup, new_row, text):
...
@@ -55,7 +60,7 @@ def add_bolded(soup, new_row, text):
return
new_row
,
soup
return
new_row
,
soup
def
create_description
(
soup
,
language
,
signatures
):
def
create_description
(
soup
,
language
,
signatures
,
type
):
""" Insert the new Python / Java table after the current html c++ table """
""" Insert the new Python / Java table after the current html c++ table """
assert
signatures
assert
signatures
tmp_table
=
soup
.
new_tag
(
'table'
)
tmp_table
=
soup
.
new_tag
(
'table'
)
...
@@ -64,7 +69,7 @@ def create_description(soup, language, signatures):
...
@@ -64,7 +69,7 @@ def create_description(soup, language, signatures):
new_row
,
soup
=
new_line
(
soup
,
tmp_table
,
new_row
)
new_row
,
soup
=
new_line
(
soup
,
tmp_table
,
new_row
)
for
s
in
signatures
:
for
s
in
signatures
:
new_row
,
soup
=
new_line
(
soup
,
tmp_table
,
new_row
)
new_row
,
soup
=
new_line
(
soup
,
tmp_table
,
new_row
)
new_row
,
soup
=
add_signature_to_table
(
soup
,
new_row
,
s
,
language
)
new_row
,
soup
=
add_signature_to_table
(
soup
,
new_row
,
s
,
language
,
type
)
new_row
,
soup
=
new_line
(
soup
,
tmp_table
,
new_row
)
new_row
,
soup
=
new_line
(
soup
,
tmp_table
,
new_row
)
return
tmp_table
,
soup
return
tmp_table
,
soup
...
@@ -79,25 +84,36 @@ def get_anchor_list(anchor, soup):
...
@@ -79,25 +84,36 @@ def get_anchor_list(anchor, soup):
a_list
.
append
(
a
)
a_list
.
append
(
a
)
return
a_list
return
a_list
def
append_python_signatures_to_table
(
soup
,
signatures
,
table
):
def
is_static_method
(
element
):
description
,
soup
=
create_description
(
soup
,
"Python:"
,
signatures
)
if
element
.
name
==
"table"
:
description
[
'class'
]
=
'python_language'
tmp_element
=
element
.
find
(
'td'
,
{
'class'
:
'memname'
})
old
=
table
.
next_sibling
if
tmp_element
is
not
None
:
if
old
.
name
!=
'table'
:
if
'static'
in
tmp_element
.
text
:
old
=
None
return
True
elif
not
'python_language'
in
old
.
get
(
'class'
,
[]):
old
=
None
# if already existed replace with the new
if
old
is
None
:
table
.
insert_after
(
description
)
else
:
else
:
old
.
replace_with
(
description
)
if
element
[
'class'
][
0
]
==
'memItemRight'
:
table
.
insert_after
(
description
)
if
"static"
in
element
.
previousSibling
.
text
:
return
True
return
False
def
append_python_signatures_to_table
(
soup
,
signatures
,
table
,
type
):
if
type
==
"method"
:
if
is_static_method
(
table
):
type
=
"static"
+
type
description
,
soup
=
create_description
(
soup
,
"Python:"
,
signatures
,
type
)
description
[
'class'
]
=
'python_language'
soup
=
insert_or_replace
(
soup
,
table
,
description
,
"table"
,
"python_language"
)
return
soup
return
soup
def
get_heading_text
(
a
):
def
get_heading_text
(
a
):
str
=
""
str
=
""
element
=
a
.
parent
.
parent
element
=
a
.
parent
if
element
is
not
None
:
childs
=
element
.
find_all
(
'a'
)
# the anchor should not be an argument of a function / method
if
childs
.
index
(
a
)
is
not
0
:
return
str
element
=
element
.
parent
if
element
is
not
None
:
if
element
is
not
None
:
if
element
.
has_attr
(
'class'
):
if
element
.
has_attr
(
'class'
):
tmp_class
=
element
[
"class"
][
0
]
tmp_class
=
element
[
"class"
][
0
]
...
@@ -105,56 +121,80 @@ def get_heading_text(a):
...
@@ -105,56 +121,80 @@ def get_heading_text(a):
str
=
element
.
parent
.
find
(
"tr"
)
.
text
str
=
element
.
parent
.
find
(
"tr"
)
.
text
return
str
return
str
def
append_python_signatures_to_heading
(
soup
,
signatures
,
element
,
href
):
def
insert_or_replace
(
soup
,
element
,
description
,
tag_name
,
tag_class
):
old
=
element
.
next_sibling
if
old
is
not
None
:
if
old
.
name
!=
tag_name
:
old
=
None
elif
not
tag_class
in
old
.
get
(
'class'
,
[]):
old
=
None
# if already existed replace with the new
if
old
is
None
:
element
.
insert_after
(
description
)
else
:
old
.
replace_with
(
description
)
return
soup
def
new_heading_td
(
soup
,
s
,
href
,
type
):
if
href
is
None
:
attrs
=
{
'class'
:
'memItemLeft'
,
'valign'
:
'top'
,
'align'
:
'right'
}
new_td
=
soup
.
new_tag
(
'td'
,
**
attrs
)
new_td
.
append
(
str
(
s
.
get
(
'ret'
,
None
)))
else
:
attrs
=
{
'class'
:
'memItemRight'
,
'valign'
:
'bottom'
}
new_td
=
soup
.
new_tag
(
'td'
,
**
attrs
)
# make the function name linkable
attrs_a
=
{
'class'
:
'el'
,
'href'
:
href
}
new_a
=
soup
.
new_tag
(
'a'
,
**
attrs_a
)
tmp_name
=
str
(
s
.
get
(
'name'
,
None
))
if
type
is
not
"method"
:
tmp_name
=
"cv2."
+
tmp_name
else
:
tmp_name
=
"obj."
+
tmp_name
new_a
.
append
(
tmp_name
)
new_td
.
append
(
new_a
)
new_td
.
append
(
"("
+
s
[
'arg'
]
+
")"
)
return
soup
,
new_td
def
append_python_signatures_to_heading
(
soup
,
signatures
,
element
,
href
,
type
):
if
type
==
"method"
:
if
is_static_method
(
element
):
type
=
"static"
+
type
for
s
in
signatures
:
for
s
in
signatures
:
attrs
=
{
'class'
:
'memitem:python'
}
attrs
=
{
'class'
:
'memitem:python'
}
new_tr
=
soup
.
new_tag
(
'tr'
,
**
attrs
)
new_tr
=
soup
.
new_tag
(
'tr'
,
**
attrs
)
attrs_left
=
{
'class'
:
'memItemLeft'
,
'valign'
:
'top'
,
'align'
:
'right'
}
soup
,
new_td_left
=
new_heading_td
(
soup
,
s
,
None
,
type
)
new_td_left
=
soup
.
new_tag
(
'td'
,
**
attrs_left
)
new_td_left
.
append
(
str
(
s
.
get
(
'ret'
,
None
)))
new_tr
.
append
(
new_td_left
)
new_tr
.
append
(
new_td_left
)
attrs_right
=
{
'class'
:
'memItemRight'
,
'valign'
:
'bottom'
}
soup
,
new_td_right
=
new_heading_td
(
soup
,
s
,
href
,
type
)
new_td_right
=
soup
.
new_tag
(
'td'
,
**
attrs_right
)
attrs_a
=
{
'class'
:
'el'
,
'href'
:
href
}
new_a
=
soup
.
new_tag
(
'a'
,
**
attrs_a
)
new_a
.
append
(
'cv2.'
+
str
(
s
.
get
(
'name'
,
None
)))
new_td_right
.
append
(
new_a
)
new_td_right
.
append
(
"("
+
s
[
'arg'
]
+
")"
)
new_tr
.
append
(
new_td_right
)
new_tr
.
append
(
new_td_right
)
old
=
element
.
next_sibling
soup
=
insert_or_replace
(
soup
,
element
,
new_tr
,
"tr"
,
"memitem:python"
)
if
old
is
not
None
:
if
old
.
name
!=
'tr'
:
old
=
None
elif
not
'memitem:python'
in
old
.
get
(
'class'
,
[]):
old
=
None
# if already existed replace with the new
if
old
is
None
:
element
.
insert_after
(
new_tr
)
else
:
old
.
replace_with
(
new_tr
)
return
soup
return
soup
def
append_python_signature
(
function_variants
,
anchor_list
,
soup
):
def
append_python_signature
(
function_variants
,
anchor_list
,
soup
):
type
=
anchor_list
[
0
]
.
type
type
=
anchor_list
[
0
]
.
type
if
type
==
"fn"
:
if
type
==
"
method"
or
type
==
"
fn"
:
if
len
(
anchor_list
)
==
1
:
if
len
(
anchor_list
)
==
1
:
tmp_anchor
=
anchor_list
[
0
]
.
anchor
tmp_anchor
=
anchor_list
[
0
]
.
anchor
a_list
=
get_anchor_list
(
tmp_anchor
,
soup
)
a_list
=
get_anchor_list
(
tmp_anchor
,
soup
)
for
a
in
a_list
:
for
a
in
a_list
:
if
a
[
'href'
]
==
"#"
+
tmp_anchor
:
if
a
[
'href'
]
==
"#"
+
tmp_anchor
:
tmp_element
=
a
.
parent
# ignore the More... link <td class = mdescRight>
if
tmp_element
is
None
or
tmp_element
[
'class'
][
0
]
==
'mdescRight'
:
continue
# Function Documentation (tables)
# Function Documentation (tables)
table
=
a
.
findNext
(
'table'
)
table
=
a
.
findNext
(
'table'
)
if
table
is
not
None
:
if
table
is
not
None
:
soup
=
append_python_signatures_to_table
(
soup
,
function_variants
,
table
)
soup
=
append_python_signatures_to_table
(
soup
,
function_variants
,
table
,
type
)
continue
else
:
str
=
get_heading_text
(
a
)
str
=
get_heading_text
(
a
)
if
"Functions"
in
str
:
if
"Functions"
in
str
:
soup
=
append_python_signatures_to_heading
(
soup
,
function_variants
,
a
.
parent
,
a
[
'href'
])
soup
=
append_python_signatures_to_heading
(
soup
,
function_variants
,
a
.
parent
,
a
[
'href'
],
type
)
print
(
"One more"
)
return
soup
return
soup
def
update_html
(
file
,
soup
):
def
update_html
(
file
,
soup
):
...
...
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