BlueStyle icon indicating copy to clipboard operation
BlueStyle copied to clipboard

Documentation for Internal Functions

Open mattBrzezinski opened this issue 3 years ago • 3 comments

Documentation is nice to define inputs/outputs and what a function does. Extending this out to internal functions would be nice as well, especially when coming back to revise the function. However, I don't think it's necessary to outline a full docstr for these internal functions.

Any thoughts on this? Suggestions for a format? Maybe something like,

function _foobar(x, y; z)
    """
    Explanation of what foobar does, maybe explain why it does things in a certain way?
    Have docstr inside the function for quick glance value that a function is internal?
    """
end

mattBrzezinski avatar Apr 19 '21 20:04 mattBrzezinski

cc: @fchorney I feel like you have thoughts around docstrs

mattBrzezinski avatar Apr 19 '21 20:04 mattBrzezinski

I just think julia docstrings in general are a little too verbose, but as far as this specific thing is considered, I'm honestly fine with defining proper docstrings for internal functions. I'm fine with just comments as well as it doesn't necessarily need a full API style docstring.

I guess I don't really have a strong preference on which style, but I think having docstrings of some sort even for internal functions is fine.

fchorney avatar Apr 19 '21 20:04 fchorney

Docstrings for internal functions should still be outside the function. That way ? can be used with them. And you can generate a docs page for the internals. ChainRulesCore and TimeZones.jl both have such pages in their docs.

I would say that they are optional, and don't have to follow the format. Including can be written on 1 line. And that

"Fixes the thing"
function fix_thing()
...
end

Should be preferred over

#Fixes the thing
function fix_thing()
...
end

oxinabox avatar Apr 19 '21 20:04 oxinabox