|
| 1 | +""" |
| 2 | +This docstring is attached to the [`Showcase`](@ref) module itself. |
| 3 | +
|
| 4 | +The [`EXPORTS`](@ref) abbreviation creates a bulleted list of all the exported names: |
| 5 | +
|
| 6 | +$(EXPORTS) |
| 7 | +
|
| 8 | +Similarly, the [`IMPORTS`](@ref) abbreviation lists all the imported modules: |
| 9 | +
|
| 10 | +$(IMPORTS) |
| 11 | +
|
| 12 | +The [`README`](@ref) can be used to include the `README.md` file in a docstring. The content |
| 13 | +between the horizontal lines is spliced by the abbreviation: |
| 14 | +
|
| 15 | +--- |
| 16 | +
|
| 17 | +$(README) |
| 18 | +
|
| 19 | +--- |
| 20 | +
|
| 21 | +The [`LICENSE`](@ref) abbreviation can be used in the same way for the `LICENSE.md` file. |
| 22 | +""" |
| 23 | +module Showcase |
| 24 | +using DocStringExtensions |
| 25 | + |
| 26 | +""" |
| 27 | +This docstring is attached to an [empty function |
| 28 | +definitions](https://docs.julialang.org/en/v1/manual/methods/#Empty-generic-functions-1). |
| 29 | +The [`METHODLIST`](@ref) abbreviation allows you to list all the methods though: |
| 30 | +
|
| 31 | +$(METHODLIST) |
| 32 | +""" |
| 33 | +function foo end |
| 34 | + |
| 35 | +""" |
| 36 | +This docstring is attached to a method that uses default values for some positional |
| 37 | +arguments: `foo(x::Int, y=3)`. |
| 38 | +
|
| 39 | +As this effectively means that there are two different methods taking different numbers of |
| 40 | +arguments, the [`SIGNATURES`](@ref) abbreviation produces the following result: |
| 41 | +
|
| 42 | +$(SIGNATURES) |
| 43 | +
|
| 44 | +--- |
| 45 | +
|
| 46 | +The [`TYPEDSIGNATURES`](@ref) abbreviation can be used to also get the types of the |
| 47 | +variables in the function signature: |
| 48 | +
|
| 49 | +$(TYPEDSIGNATURES) |
| 50 | +
|
| 51 | +--- |
| 52 | +
|
| 53 | +The [`FUNCTIONNAME`](@ref) abbreviation can be used to directly include the name of the |
| 54 | +function in the docstring (e.g. here: $(FUNCTIONNAME)). This can be useful when writing your |
| 55 | +own type signatures: |
| 56 | +
|
| 57 | + $(FUNCTIONNAME)(x, ...) |
| 58 | +""" |
| 59 | +foo(x::Int, y=3) = nothing |
| 60 | + |
| 61 | +""" |
| 62 | +A different method for [`$(FUNCTIONNAME)`](@ref). [`SIGNATURES`](@ref) abbreviation: |
| 63 | +
|
| 64 | +$(SIGNATURES) |
| 65 | +
|
| 66 | +And the [`TYPEDSIGNATURES`](@ref) abbreviation: |
| 67 | +
|
| 68 | +$(TYPEDSIGNATURES) |
| 69 | +""" |
| 70 | +foo(x::AbstractString) = nothing |
| 71 | + |
| 72 | + |
| 73 | +""" |
| 74 | +The [`TYPEDEF`](@ref) abbreviation includes the type signature: |
| 75 | +
|
| 76 | +$(TYPEDEF) |
| 77 | +
|
| 78 | +--- |
| 79 | +
|
| 80 | +The [`FIELDS`](@ref) abbreviation creates a list of all the fields of the type. |
| 81 | +If the fields has a docstring attached, that will also get included. |
| 82 | +
|
| 83 | +$(FIELDS) |
| 84 | +
|
| 85 | +--- |
| 86 | +
|
| 87 | +[`TYPEDFIELDS`](@ref) also adds in types for the fields: |
| 88 | +
|
| 89 | +$(TYPEDFIELDS) |
| 90 | +""" |
| 91 | +struct Foobar{T <: AbstractString} |
| 92 | + "Docstring for the `x` field." |
| 93 | + x :: Nothing |
| 94 | + y :: T # y is missing a docstring |
| 95 | + "Docstring for the `z` field." |
| 96 | + z :: Vector{T} |
| 97 | +end |
| 98 | + |
| 99 | +export foo, Foobar |
| 100 | + |
| 101 | +end |
0 commit comments