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
ebeab29e
Commit
ebeab29e
authored
10 years ago
by
Karl Palmen
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/bugfix/9757_docs_category_text_windows'
parents
1b6c8939
c9629022
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/docs/source/_templates/category.html
+1
-1
1 addition, 1 deletion
Code/Mantid/docs/source/_templates/category.html
Code/Mantid/docs/sphinxext/mantiddoc/directives/categories.py
+21
-18
21 additions, 18 deletions
.../Mantid/docs/sphinxext/mantiddoc/directives/categories.py
with
22 additions
and
19 deletions
Code/Mantid/docs/source/_templates/category.html
+
1
−
1
View file @
ebeab29e
...
...
@@ -19,7 +19,7 @@
<h3
style=
"font-weight:bold"
>
{{ section }}
</h3>
<ul>
{%- endif %}
<li><a
href=
"{{ item.link(out
loc
) }}"
>
{{ item.name }}
</a></li>
<li><a
href=
"{{ item.link(out
path
) }}"
>
{{ item.name }}
</a></li>
{%- set first = False -%}
{%- endfor -%}
</ul>
...
...
This diff is collapsed.
Click to expand it.
Code/Mantid/docs/sphinxext/mantiddoc/directives/categories.py
+
21
−
18
View file @
ebeab29e
...
...
@@ -7,7 +7,7 @@
"
index
"
page is controlled by a jinja2 template.
"""
from
base
import
AlgorithmBaseDirective
,
algorithm_name_and_version
from
sphinx.util.osutil
import
relative_uri
import
os
CATEGORY_PAGE_TEMPLATE
=
"
category.html
"
...
...
@@ -52,7 +52,7 @@ class LinkItem(object):
def
__repr__
(
self
):
return
self
.
name
def
link
(
self
,
source_loc
,
ext
=
"
.html
"
):
def
link
(
self
,
base
,
ext
=
"
.html
"
):
"""
Returns a link for use as a href to refer to this document from a
categories page. It assumes that the category pages are in a subdirectory
...
...
@@ -60,12 +60,12 @@ class LinkItem(object):
under the root.
Arguments:
source_loc (str): Path from source directory to item that will use the link. This must not be a filepath
base (str): The path to the referrer
Returns:
str: A string containing the link to reach this item
"""
link
=
os
.
path
.
relpath
(
self
.
location
,
start
=
source_loc
)
link
=
relative_uri
(
base
=
base
,
to
=
self
.
location
)
if
not
link
.
endswith
(
ext
):
link
+=
ext
return
link
...
...
@@ -90,7 +90,7 @@ class Category(LinkItem):
pages
=
None
# Collection of PageRef objects that form subcategories of this category
subcategories
=
None
# Relative path for the final html to be written
# Relative path for the final html to be written
. \ separators are converted to /
html_path
=
None
def
__init__
(
self
,
name
,
docname
):
...
...
@@ -101,10 +101,12 @@ 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
=
os
.
path
.
join
(
dirpath
,
CATEGORIES_DIR
)
self
.
html_path
=
os
.
path
.
join
(
html_dir
,
name
+
"
.html
"
)
html_dir
=
dirpath
+
"
/
"
+
CATEGORIES_DIR
self
.
html_path
=
html_dir
+
"
/
"
+
name
+
"
.html
"
super
(
Category
,
self
).
__init__
(
name
,
self
.
html_path
)
self
.
pages
=
set
([])
self
.
subcategories
=
set
([])
...
...
@@ -213,7 +215,6 @@ class CategoriesDirective(AlgorithmBaseDirective):
if
not
hasattr
(
env
,
"
categories
"
):
env
.
categories
=
{}
docdir
=
os
.
path
.
dirname
(
env
.
docname
)
link_rst
=
""
ncategs
=
0
for
item
in
category_list
:
...
...
@@ -237,7 +238,7 @@ class CategoriesDirective(AlgorithmBaseDirective):
parent
.
subcategories
.
add
(
Category
(
categ_name
,
env
.
docname
))
#endif
link_rst
+=
"
`%s <%s>`_ |
"
%
(
categ_name
,
category
.
link
(
docdir
))
link_rst
+=
"
`%s <%s>`_ |
"
%
(
categ_name
,
category
.
link
(
env
.
docname
))
ncategs
+=
1
parent
=
category
# endfor
...
...
@@ -294,22 +295,24 @@ def create_category_pages(app):
# sort subcategories & pages alphabetically
context
[
"
subcategories
"
]
=
sorted
(
category
.
subcategories
,
key
=
lambda
x
:
x
.
name
)
context
[
"
pages
"
]
=
sorted
(
category
.
pages
,
key
=
lambda
x
:
x
.
name
)
context
[
"
out
loc
"
]
=
os
.
path
.
dirname
(
category
.
html_path
)
context
[
"
out
path
"
]
=
category
.
html_path
#jinja appends .html to output name
category_html_path
=
os
.
path
.
splitext
(
category
.
html_path
)[
0
]
yield
(
category_html_path
,
context
,
template
)
category_html_path
_noext
=
os
.
path
.
splitext
(
category
.
html_path
)[
0
]
yield
(
category_html_path
_noext
,
context
,
template
)
# Now any additional index pages if required
if
category
.
name
in
INDEX_CATEGORIES
:
# index in categories directory
category_html_dir
=
os
.
path
.
dirname
(
category_html_path
)
context
[
"
outloc
"
]
=
category_html_dir
yield
(
category_html_dir
+
"
/index
"
,
context
,
template
)
category_html_dir
=
os
.
path
.
dirname
(
category
.
html_path
)
category_html_path_noext
=
category_html_dir
+
"
/index
"
yield
(
category_html_path_noext
,
context
,
template
)
# index in document directory
document_dir
=
os
.
path
.
dirname
(
category_html_dir
)
context
[
"
outloc
"
]
=
document_dir
yield
(
document_dir
+
"
/index
"
,
context
,
template
)
category_html_path_noext
=
document_dir
+
"
/index
"
context
[
"
outpath
"
]
=
category_html_path_noext
+
"
.html
"
yield
(
category_html_path_noext
,
context
,
template
)
# enddef
#-----------------------------------------------------------------------------------------------------------
...
...
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