Skip to content

Commit

Permalink
Fix github link in setting docs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
regisb committed Nov 9, 2020
1 parent 9b4702c commit 32370e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Change Log

.. There should always be an "Unreleased" section for changes pending release.
[0.10.1] - 2020-11-09
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Fix Github links generated by the sphinx extension for settings.


[0.10.0] - 2020-10-12
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion code_annotations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Extensible tools for parsing annotations in codebases.
"""

__version__ = '0.10.0'
__version__ = '0.10.1'
11 changes: 7 additions & 4 deletions code_annotations/contrib/sphinx/extensions/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ def iter_nodes(self):
"""
Iterate on the docutils nodes generated by this directive.
"""
source_path = os.path.join(
self.env.config.settings_source_path, self.options.get("folder_path", "")
)
folder_path = self.options.get("folder_path", "")
source_path = os.path.join(self.env.config.settings_source_path, folder_path)
settings = find_settings(source_path)
# folder_path can point to a file or directory
root_folder = folder_path if os.path.isdir(source_path) else os.path.dirname(folder_path)
for setting_name in sorted(settings):
setting = settings[setting_name]
# setting["filename"] is relative to the root_path
setting_filename = os.path.join(root_folder, setting["filename"])
setting_default_value = setting.get(".. setting_default:", "Not defined")
setting_default_node = nodes.literal(
text=quote_value(setting_default_value)
Expand All @@ -95,7 +98,7 @@ def iter_nodes(self):
refuri="{}/blob/{}/{}#L{}".format(
self.env.config.settings_repo_url,
self.env.config.settings_repo_version,
setting["filename"],
setting_filename,
setting["line_number"],
),
),
Expand Down

0 comments on commit 32370e1

Please sign in to comment.