Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolution of reference tags in a referenced docstring #1487

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

notEthan
Copy link
Contributor

@notEthan notEthan commented Mar 6, 2023

When a docstring X is a reference to another docstring Y, any reference tags within docstring Y are resolved using the namespace of X, causing resolution to fail when X and Y are in different namespaces. This PR adds Docstring#namespace which follows the resolved reference.

Completed Tasks

  • I have read the Contributing Guide.
  • The pull request is complete (implemented / written).
  • Git commits have been cleaned up (squash WIP / revert commits).
  • I wrote tests and ran bundle exec rake locally (if code is attached to PR).

Copy link
Owner

@lsegal lsegal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some thoughts.

@@ -102,6 +106,7 @@ def self.new!(text, tags = [], object = nil, raw_data = nil, ref_object = nil)
# with.
def initialize(content = '', object = nil)
@object = object
@namespace = object
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kind of seems like .namespace is just a dupe of .object? Or, at the very least, that namespace could be a combination of @object || @unresolved_reference and thus no attribute would be needed.

@@ -224,7 +224,8 @@ def create_tag(tag_name, tag_buf = '')

# Creates a {Tags::RefTag}
def create_ref_tag(tag_name, name, object_name)
@tags << Tags::RefTagList.new(tag_name, P(object, object_name), name)
namespace = object && object.docstring ? object.docstring.namespace : object
@tags << Tags::RefTagList.new(tag_name, P(namespace, object_name), name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(See above) I could be wrong but it seems like namespace could be replaced entirely by object || @unresolved_reference and thus be the only necessary line of implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants