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

Parameterized type in function spec generates an extra anchor tag #657

Closed
jschneider1207 opened this issue Dec 28, 2016 · 2 comments · Fixed by #694
Closed

Parameterized type in function spec generates an extra anchor tag #657

jschneider1207 opened this issue Dec 28, 2016 · 2 comments · Fixed by #694

Comments

@jschneider1207
Copy link

jschneider1207 commented Dec 28, 2016

I have something similar to the following defined:

@type t :: term
@opaque finger_tree(t) :: ...

@spec append(finger_tree(t), t) :: finger_tree(t)
def append(arg, y) do
 ...
end

When docs are generated for this, the entry for append looks like

image

It appears that it is trying to add another link to the entry for type t

@jschneider1207 jschneider1207 changed the title Parameterized type in function specs generates an extra anchor tag Parameterized type in function spec generates an extra anchor tag Dec 28, 2016
@ericmj
Copy link
Member

ericmj commented Dec 29, 2016

None of them should link to t since they are parameters and can therefor be any type.

@ymtszw
Copy link
Contributor

ymtszw commented Mar 25, 2017

@ericmj I think you mentioned about docs for "type definition" in which it's true that parameters in parameterized types can be arbitrary so not to be linked even if it is named as t (or any other names identical to existing local types).

On the other hand, in docs for "function typespecs", actual, concrete types can be specified as parameters in parameterized types, so they are to be linked.
I think @sschneider1207 meant about that, and I agree with that.
Current handling of parameterized types in typespec doc generation escapes links generated for type parameters where it should not. Resulting in situations like the image in first post.

For instance,

@type t :: term
@type parameterized_t(t) :: {:ok, t} | {:error, term}

@spec fun(t) :: parameterized_t(t)
def fun(val) do
  # some logic returning parameterized_t/1
end

The above code should generate docs for fun/1 typespec in HTML like this:

fun(<a href="#t:t/0">t</a>) :: <a href="#t:parameterized_t/1">parameterized_t</a>(<a href="#t:t/0">t</a>)

I have PR'ed the fix achieving the above behavior, so please review it ❤️ => #694

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

Successfully merging a pull request may close this issue.

3 participants