-
Notifications
You must be signed in to change notification settings - Fork 31
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
FUNCTIONNAME inside a function that generates the docstring #149
Comments
Unlikely to ever be something that's doable due to how the docsystem's macros work. You could implement a separate version of What is it you're trying to do with the |
It came up here: SciML/OrdinaryDiffEq.jl#1866 |
Ah, thanks for the link. |
In reference to SciML/OrdinaryDiffEq.jl#1866 (comment), I don't think an Any thoughts on how we could apply different templates to different groups within a module? The only thing that crosses my mind right now is, as you suggested, re-implementing With a custom macro doc ... end
function my_docstring_generator(ex)
return "..."
end
@doc my_docstring_generator
function foo end Closures could maybe be used to add local parameters (like the unique parts of a docstring): function my_docstring_generator(s)
ex -> begin
return "... $s"
end
end
@doc my_docstring_generator("this function foos")
function foo end And the custom |
So maybe the question we need to answer then is how should we mark a particular function/type/thing as being part of a specific group. Once we have that, then getting the template system to handle arbitrary groups would be relatively simple. Custom Perhaps just a way to mark a specific docstring as using a particular template would work, e.g. const CUSTOM_TEMPLATE = @template(
"""
$SIGNATURE
$DOCSTRING
"""
)
"""
$CUSTOM_TEMPLATE
...
"""
function func_1()
end
"""
$CUSTOM_TEMPLATE
...
"""
function func_2()
end And then when we encounter a docstring that happens to be interpolating a |
Yeah, agreed, this feels a bit hacky. I like the const CUSTOM_TEMPLATE = template() do docstring, documented_expr
... # returns a String? Markdown.MD?
end I am not sure if DocStringExtensions has access to the expression you're documenting. I guess it must, since it needs to determine the function names, and arguments, and such? |
Possibly.
We do now capture the expression (#133), but all the names, arguments, etc. are being looked up via runtime reflection since that's how it originally was done, and for some data it's probably best to continue using it. |
Is it possible to get FUNCTIONNAME to work inside a function that generates the docstring? Something similar to
The text was updated successfully, but these errors were encountered: