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
687690b0
Commit
687690b0
authored
9 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Renamed variable to be clearer
parent
b41633d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/sphinxext/mantiddoc/directives/sourcelink.py
+12
-8
12 additions, 8 deletions
docs/sphinxext/mantiddoc/directives/sourcelink.py
with
12 additions
and
8 deletions
docs/sphinxext/mantiddoc/directives/sourcelink.py
+
12
−
8
View file @
687690b0
...
...
@@ -45,7 +45,10 @@ class SourceLinkDirective(AlgorithmBaseDirective):
file_types
=
{
"
h
"
:
"
C++ header
"
,
"
cpp
"
:
"
C++ source
"
,
"
py
"
:
"
Python
"
}
file_lookup
=
{}
mantid_directory_cache
=
None
# will be filled in
__source_root
=
None
def
execute
(
self
):
"""
...
...
@@ -121,24 +124,25 @@ class SourceLinkDirective(AlgorithmBaseDirective):
#value is not present
return
None
def
get_mantid_directory
(
self
):
@property
def
source_root
(
self
):
"""
returns the
Code\Mantid
directory
returns the
root source
directory
"""
if
self
.
mantid_directory_cache
is
None
:
if
self
.
__source_root
is
None
:
env
=
self
.
state
.
document
.
settings
.
env
direc
=
env
.
srcdir
#= C:\Mantid\Code\Mantid\docs\source
direc
=
os
.
path
.
join
(
direc
,
"
..
"
,
"
..
"
)
# assume root is two levels up
direc
=
os
.
path
.
abspath
(
direc
)
self
.
mantid_directory_cache
=
direc
return
self
.
mantid_directory_cache
self
.
__source_root
=
direc
return
self
.
__source_root
def
parse_source_tree
(
self
):
"""
Fills the file_lookup dictionary after parsing the source code
"""
for
dirName
,
subdirList
,
fileList
in
os
.
walk
(
self
.
get_mantid_directory
()
):
for
dirName
,
subdirList
,
fileList
in
os
.
walk
(
self
.
source_root
):
for
fname
in
fileList
:
(
baseName
,
fileExtension
)
=
os
.
path
.
splitext
(
fname
)
#strip the dot from the extension
...
...
@@ -208,7 +212,7 @@ class SourceLinkDirective(AlgorithmBaseDirective):
url
=
file_path
# remove the directory path
url
=
url
.
replace
(
self
.
get_mantid_directory
()
,
""
)
url
=
url
.
replace
(
self
.
source_root
,
""
)
#harmonize slashes
url
=
url
.
replace
(
"
\\
"
,
"
/
"
)
#prepend the github part
...
...
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