Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
33a2d8f3
Commit
33a2d8f3
authored
9 years ago
by
Nick Draper
Browse files
Options
Downloads
Patches
Plain Diff
Adjust category creation to handle subcategories better
re #14381
parent
8a9895fb
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/sphinxext/mantiddoc/directives/categories.py
+41
-27
41 additions, 27 deletions
docs/sphinxext/mantiddoc/directives/categories.py
with
41 additions
and
27 deletions
docs/sphinxext/mantiddoc/directives/categories.py
+
41
−
27
View file @
33a2d8f3
...
...
@@ -34,7 +34,9 @@ class LinkItem(object):
name (str): Display name of document
location (str): Location of item relative to source directory
"""
self
.
name
=
str
(
name
)
name
=
str
(
name
)
name
=
name
.
replace
(
"
\\\\
"
,
"
\\
"
)
self
.
name
=
name
self
.
location
=
location
def
__eq__
(
self
,
other
):
...
...
@@ -61,6 +63,7 @@ class LinkItem(object):
Arguments:
base (str): The path to the referrer
ext (str): The extension to use
Returns:
str: A string containing the link to reach this item
...
...
@@ -101,16 +104,17 @@ class Category(LinkItem):
name (str): The name of the category
docname (str): Relative path to document from root directory
"""
if
"
\\
"
in
docname
:
docname
=
docname
.
replace
(
"
\\
"
,
"
/
"
)
dirpath
,
filename
=
os
.
path
.
split
(
docname
)
html_dir
=
dirpath
+
"
/
"
+
CATEGORIES_DIR
self
.
html_path
=
html_dir
+
"
/
"
+
name
+
"
.html
"
self
.
html_path
=
html_dir
+
"
/
"
+
name
.
replace
(
"
\\\\
"
,
"
/
"
)
+
"
.html
"
super
(
Category
,
self
).
__init__
(
name
,
self
.
html_path
)
self
.
pages
=
set
([])
self
.
subcategories
=
set
([])
#endclass
class
CategoriesDirective
(
AlgorithmBaseDirective
):
...
...
@@ -235,31 +239,31 @@ class CategoriesDirective(AlgorithmBaseDirective):
link_rst
=
""
ncategs
=
0
for
item
in
category_list
:
if
r
"
\\
"
in
item
:
categs
=
item
.
split
(
r
"
\\
"
)
else
:
categs
=
[
item
]
# endif
parent
=
None
for
index
,
categ_name
in
enumerate
(
categs
):
if
categ_name
not
in
env
.
categories
:
category
=
Category
(
categ_name
,
env
.
docname
)
env
.
categories
[
categ_name
]
=
category
for
categ_name
in
category_list
:
#categ_name is the full category name - register that
category
=
self
.
register_category
(
categ_name
,
env
)
category
.
pages
.
add
(
PageRef
(
page_name
,
env
.
docname
))
#now step up a step up each time the category hierarchy
parent_category
=
categ_name
;
while
True
:
if
r
"
\\
"
in
parent_category
:
categs
=
parent_category
.
split
(
r
"
\\
"
)
else
:
category
=
env
.
categories
[
categ_name
]
#endif
category
.
pages
.
add
(
PageRef
(
page_name
,
env
.
docname
))
if
index
>
0
:
# first is never a child
parent
.
subcategories
.
add
(
Category
(
categ_name
,
env
.
docname
))
#endif
link_rst
+=
"
`%s <%s>`_ |
"
%
(
categ_name
,
category
.
link
(
env
.
docname
))
ncategs
+=
1
parent
=
category
# endfor
break
# remove the last item
categs
.
pop
()
parent_category
=
r
"
\\
"
.
join
(
categs
)
#register the parent category
parent
=
self
.
register_category
(
parent_category
,
env
)
parent
.
subcategories
.
add
(
Category
(
categ_name
,
env
.
docname
))
# endwhile
#category should be the last subcategory by this point
link_rst
+=
"
`%s <%s>`_ |
"
%
(
categ_name
,
category
.
link
(
env
.
docname
))
ncategs
+=
1
# endfor
link_rst
=
"
**%s**:
"
+
link_rst
.
rstrip
(
"
|
"
)
# remove final separator
...
...
@@ -272,6 +276,16 @@ class CategoriesDirective(AlgorithmBaseDirective):
return
link_rst
#end def
def
register_category
(
self
,
categ_name
,
env
):
category
=
Category
(
categ_name
,
env
.
docname
)
if
categ_name
not
in
env
.
categories
:
category
=
Category
(
categ_name
,
env
.
docname
)
env
.
categories
[
categ_name
]
=
category
else
:
category
=
env
.
categories
[
categ_name
]
return
category
#---------------------------------------------------------------------------------
def
html_collect_pages
(
app
):
...
...
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