You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my shard, I extend a struct from another library by adding some convenience methods. I defined an alias in my namespace to the struct in the external namespace.
Now, crystal docs just generates a page with the alias definition (which contains an invalid link to the external struct) without bothering to create a page with the new methods.
This, however, only happens when I extend a class/struct/module that a library already defined (see notes)
# lib/a/src/a.crmoduleA# A very useful structstructTestdefinitialize(@prop : Int32); endendend# src/main.crrequire"a"moduleBaliasTest=A::TeststructA::Test# Multiplies @prop with the given factordefmultiply(factor)
@prop* factor
endendendtest=B::Test.new(3)
puts test.multiply(5)
Generate docs: crystal docs --project-name Test --project-version 1.0.0
Result:
Expectation
My expectation was that this would generate another page under the A module in which the added methods were described.
Notes
When the alias is removed, no page is generated at all
When the external struct from module A is extended at the toplevel (not inside module B), the result is the same
When no library defines module A, the result is as expected
The text was updated successfully, but these errors were encountered:
For some reason, module B; struct A::Test; reopens ::A::Test. That's wrong. It should actually create a new type B::A::Test because the struct definition is in the B namespace.
I suppose the docs generator might be expecting this and that's the reason why it doesn't even show A::Test. It would be documented if you remove the B namespace.
@straight-shoota You are right, that is, however, another issue I was not even going for ^^ (but the code above compiles, btw i don't know why though).
I did a little research on my end:
It seems that my issue has a different root cause. For some reason, if I extend the external struct like this:
moduleAstructTestdefmethod(); endendend
it is documented as expected.
If I write the short form like this:
structA::Testdefmethod(); endend
it is not documented.
If I declare a new struct B::Test, everything works just fine.
Somehow, the short form is treated differently than the verbose one.
In my shard, I extend a struct from another library by adding some convenience methods. I defined an alias in my namespace to the struct in the external namespace.
Now,
crystal docs
just generates a page with the alias definition (which contains an invalid link to the external struct) without bothering to create a page with the new methods.This, however, only happens when I extend a class/struct/module that a library already defined (see notes)
Steps to reproduce:
crystal docs --project-name Test --project-version 1.0.0
Expectation
My expectation was that this would generate another page under the
A
module in which the added methods were described.Notes
The text was updated successfully, but these errors were encountered: