Comments (5)
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.
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.
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.
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)
- How to use alias of AbstractArray instead of the full name? (Feature request) HOT 2
- Display parametric types in a better way? HOT 2
- Remove documentation page for v0.1
- Update CI badges in the README HOT 2
- TagBot trigger issue HOT 7
- The `TYPES` template does not apply to parametric types
- MODULES key not found for `@template` HOT 1
- Doctest failures
- Format docstrings HOT 4
- Considering writing a script to add function signatures to a code base. HOT 5
- expected test failure from the incoming `Core.Compiler` changes HOT 3
- Cannot get source for generated functions
- feature request: non-api doc marker HOT 7
- How to show default values and types of keyword arguments? HOT 1
- Update docs to latest version of Documenter HOT 5
- different abbreviations for concrete and abstract types HOT 1
- FUNCTIONNAME inside a function that generates the docstring HOT 7
- Would it be possible to add a TYPEDMETHODLIST abbreviation HOT 2
- Internal errors when (ab)using `@template` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docstringextensions.jl.