-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of constants that are just aliases
* In the constant summary, link to its target object * When linking from other locations, link directly to the target.
- Loading branch information
Showing
6 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
RSpec.describe YARD::CodeObjects::ConstantObject do | ||
before do | ||
Registry.clear | ||
end | ||
|
||
describe "#target" do | ||
it "resolves" do | ||
const1 = ConstantObject.new(:root, :A) | ||
const2 = ConstantObject.new(:root, :B) | ||
const2.value = "A" | ||
expect(const2.target).to eq const1 | ||
end | ||
|
||
it "returns nil for an integer value" do | ||
const = ConstantObject.new(:root, :A) | ||
const.value = "1" | ||
expect(const.target).to be_nil | ||
end | ||
|
||
it "returns nil for a string value" do | ||
const = ConstantObject.new(:root, :A) | ||
const.value = '"String"' | ||
expect(const.target).to be_nil | ||
end | ||
|
||
it "returns nil for an empty value" do | ||
const = ConstantObject.new(:root, :A) | ||
const.value = "" | ||
expect(const.target).to be_nil | ||
end | ||
|
||
it "returns nil for an explicit self-referential constant" do | ||
const = ConstantObject.new(:root, :A) | ||
const.value = "A" | ||
expect(const.target).to be_nil | ||
end | ||
|
||
it "returns nil for an explicit self-referential constant" do | ||
mod = ModuleObject.new(:root, :M) | ||
const = ConstantObject.new(mod, :A) | ||
const.value = "self" | ||
expect(const.target).to be_nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<h1>Module: A | ||
|
||
|
||
|
||
</h1> | ||
<div class="box_info"> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<dl> | ||
<dt>Defined in:</dt> | ||
<dd>(stdin)</dd> | ||
</dl> | ||
|
||
</div> | ||
|
||
<h2>Overview</h2><div class="docstring"> | ||
<div class="discussion"> | ||
Checkout BAR | ||
|
||
</div> | ||
</div> | ||
<div class="tags"> | ||
|
||
|
||
</div> | ||
|
||
<h2> | ||
Constant Summary | ||
<small><a href="#" class="constants_summary_toggle">collapse</a></small> | ||
</h2> | ||
|
||
<dl class="constants"> | ||
|
||
<dt id="FOO-constant" class="">FOO = | ||
|
||
</dt> | ||
<dd><pre class="code">1</pre></dd> | ||
|
||
<dt id="BAR-constant" class="">BAR = | ||
|
||
</dt> | ||
<dd>FOO</dd> | ||
|
||
</dl> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters