Giter VIP home page Giter VIP logo

Comments (5)

andyDoucette avatar andyDoucette commented on July 22, 2024 2

Thanks for the clarification on FIELDS! I'll have to read the section on julia macros to understand your suggestion. Just so this doesn't get closed prematurely, the most important part of this issue is to get a page of examples if at all possible. 🙏

from docstringextensions.jl.

tpapp avatar tpapp commented on July 22, 2024

AFAIK FIELDS is for documenting fields of a composite type (struct, mutable struct), not function arguments.

Typically one does something like

"""
$(SIGNATURES)

# Arguments

- `startingAmount`: how much money you have now
- ...
"""
function calculate_retirement_monthly_savings(startingAmount::Number, ...

which indeed duplicates argument names.

from docstringextensions.jl.

MichaelHatherly avatar MichaelHatherly commented on July 22, 2024

Yes, FIELDS is for structs. You could write a macro that wraps a function definition and it's docstring that allows you to avoid extra typing and works something like

@document_arguments begin
    """
    $(ARGUMENTS)
    """
    function func(
        "docs for `arg`" ->
        arg,
    )
        # ...
    end
end

which would pull out the "..." -> expressions and place them in a formatted list in place of ARGUMENTS.

from docstringextensions.jl.

prakaa avatar prakaa commented on July 22, 2024

On this, I think it could be helpful to document/include an example on how to use @template, e.g.:

Define your templates in your PackageName.jl. This must be done before including files:

...
#DocStringExtensions Templates
using DocStringExtensions
@template (FUNCTIONS, METHODS) = """
                                 $(TYPEDSIGNATURES)
                                 $(DOCSTRING)
                                 $(METHODLIST)
                                 """
@template TYPES = """
                  $(TYPEDEF)
                  $(TYPEDFIELDS)
                  $(DOCSTRING)
                  """
# file includes
include("somefile1.jl")
include("somefile2.jl")
...

This could also address #117

from docstringextensions.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.