-
Notifications
You must be signed in to change notification settings - Fork 30
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
Move template expansion to "format-time" #96
Move template expansion to "format-time" #96
Conversation
This moves the expansion of templates from macro expansion time to later on. This allows us to avoid having to search through expressions looking for the actual expression type since those may be hidden by "decorator" macros. It also handles cases where `@doc` is used on a string macro docstring, such as @doc raw"..." f(x) = x Implementation is based on a new internal abbreviation type called `Template` which gets prepended and appended to docstrings in modules where templates are available. Then, during formatting, we expand these `Template` abbreviations into there definitions. Fixes JuliaDocs#73.
Failures on 1.6 due to #93. Unrelated to this change. |
Changes tuple comparision from a roundabout string comparision to use proper subtype comparision. Also adjusts test cases to avoid triggering type alias printing such as `Array{T,1}` to `Vector{T}` which fails on Julia 1.6.
Commit added for fixes for #93.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment there are no tests for #73, right?
:typesig => Union{Tuple{Union{T, Nothing}}, Tuple{Union{T, Nothing}, T}, Tuple{T}} where T <: Number, | ||
:typesig => Union{Tuple{Union{T, Nothing}}, Tuple{Union{T, Nothing}, T}, Tuple{T}} where T <: Integer, | ||
:module => M, | ||
) | ||
DSE.format(DSE.TYPEDSIGNATURES, buf, doc) | ||
str = String(take!(buf)) | ||
@test occursin("\n```julia\n", str) | ||
@test occursin("\nk_7(x::Union{Nothing, T<:Number}) -> Union{Nothing, Number}\n", str) | ||
@test occursin("\nk_7(x::Union{Nothing, T<:Number}, y::T<:Number) -> Union{Nothing, T<:Number}\n", str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the Vector
/Matrix
changes, but is there a similar printing change with Number
prompting the Number
-> Integer
change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly. It may also be due to use of return_type
to determine types after ->
which means all bets are off for cross-version compat here.
|
No worries @bzinberg 👍 |
This moves the expansion of templates from macro expansion time to later on. This allows us to avoid having to search through expressions looking for the actual expression type since those may be hidden by "decorator" macros. It also handles cases where
@doc
is used on a string macro docstring, such asImplementation is based on a new internal abbreviation type called
Template
which gets prepended and appended to docstrings in modules where templates are available. Then, during formatting, we expand theseTemplate
abbreviations into there definitions.Fixes #73.