Skip to content

Commit 32370e1

Browse files
committed
Fix github link in setting docs
The "filename" value returned by a static search is relative to the AnnotationConfig.source_path attribute. As a consequence, when we used the sphinx extension to document settings with `:folder_path: lms/envs/common.py` this resulted in incorrect links, such as: https://github.com/edx/edx-platform/blob/97e9fee92ed2c553e6a669f8ffba9151b122129d/common.py#L57 Compare to the correct link: https://github.com/edx/edx-platform/blob/97e9fee92ed2c553e6a669f8ffba9151b122129d/lms/envs/common.py#L57
1 parent 9b4702c commit 32370e1

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ Change Log
1111

1212
.. There should always be an "Unreleased" section for changes pending release.
1313
14+
[0.10.1] - 2020-11-09
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
17+
* Fix Github links generated by the sphinx extension for settings.
18+
19+
1420
[0.10.0] - 2020-10-12
1521
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1622

code_annotations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Extensible tools for parsing annotations in codebases.
33
"""
44

5-
__version__ = '0.10.0'
5+
__version__ = '0.10.1'

code_annotations/contrib/sphinx/extensions/settings.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,15 @@ def iter_nodes(self):
7272
"""
7373
Iterate on the docutils nodes generated by this directive.
7474
"""
75-
source_path = os.path.join(
76-
self.env.config.settings_source_path, self.options.get("folder_path", "")
77-
)
75+
folder_path = self.options.get("folder_path", "")
76+
source_path = os.path.join(self.env.config.settings_source_path, folder_path)
7877
settings = find_settings(source_path)
78+
# folder_path can point to a file or directory
79+
root_folder = folder_path if os.path.isdir(source_path) else os.path.dirname(folder_path)
7980
for setting_name in sorted(settings):
8081
setting = settings[setting_name]
82+
# setting["filename"] is relative to the root_path
83+
setting_filename = os.path.join(root_folder, setting["filename"])
8184
setting_default_value = setting.get(".. setting_default:", "Not defined")
8285
setting_default_node = nodes.literal(
8386
text=quote_value(setting_default_value)
@@ -95,7 +98,7 @@ def iter_nodes(self):
9598
refuri="{}/blob/{}/{}#L{}".format(
9699
self.env.config.settings_repo_url,
97100
self.env.config.settings_repo_version,
98-
setting["filename"],
101+
setting_filename,
99102
setting["line_number"],
100103
),
101104
),

0 commit comments

Comments
 (0)