Skip to content

Commit 1ccf7dd

Browse files
committed
Add headers in docstrings
1 parent fd40488 commit 1ccf7dd

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

src/config.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Base.Broadcast.broadcastable(config::RuleConfig) = Ref(config)
3131
abstract type ReverseModeCapability end
3232

3333
"""
34-
HasReverseMode
34+
HasReverseMode <: ReverseModeCapability
3535
3636
This trait indicates that a `RuleConfig{>:HasReverseMode}` can perform reverse mode AD.
3737
If it is set then [`rrule_via_ad`](@ref) must be implemented.
3838
"""
3939
struct HasReverseMode <: ReverseModeCapability end
4040

4141
"""
42-
NoReverseMode
42+
NoReverseMode <: ReverseModeCapability
4343
4444
This is the complement to [`HasReverseMode`](@ref). To avoid ambiguities [`RuleConfig`]s
4545
that do not support performing reverse mode AD should be `RuleConfig{>:NoReverseMode}`.
@@ -49,15 +49,15 @@ struct NoReverseMode <: ReverseModeCapability end
4949
abstract type ForwardsModeCapability end
5050

5151
"""
52-
HasForwardsMode
52+
HasForwardsMode <: ForwardsModeCapability
5353
5454
This trait indicates that a `RuleConfig{>:HasForwardsMode}` can perform forward mode AD.
5555
If it is set then [`frule_via_ad`](@ref) must be implemented.
5656
"""
5757
struct HasForwardsMode <: ForwardsModeCapability end
5858

5959
"""
60-
NoForwardsMode
60+
NoForwardsMode <: ForwardsModeCapability
6161
6262
This is the complement to [`HasForwardsMode`](@ref). To avoid ambiguities [`RuleConfig`]s
6363
that do not support performing forwards mode AD should be `RuleConfig{>:NoForwardsMode}`.

src/rule_definition_tools.jl

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,18 @@ end
269269

270270
# For context on why this is important, see
271271
# https://github.com/JuliaDiff/ChainRulesCore.jl/pull/276
272-
"Declares properly hygenic inputs for propagation expressions"
272+
"""
273+
_propagator_inputs(n)
274+
275+
Declares properly hygenic inputs for propagation expressions
276+
"""
273277
_propagator_inputs(n) = [esc(gensym(Symbol(, i))) for i in 1:n]
274278

275-
"given the variable names, escaped but without types, makes setup expressions for projection operators"
279+
"""
280+
_make_projectors(xs)
281+
282+
Given the variable names, escaped but without types, makes setup expressions for projection operators
283+
"""
276284
function _make_projectors(xs)
277285
projs = map(x -> Symbol(:proj_, x.args[1]), xs)
278286
setups = map((x, p) -> :($p = ProjectTo($x)), xs, projs)
@@ -393,7 +401,11 @@ macro non_differentiable(sig_expr)
393401
end
394402
end
395403

396-
"changes `f(x,y)` into `f(x,y; kwargs....)`"
404+
"""
405+
_with_kwargs_expr(call_expr, kwargs)
406+
407+
Changes `f(x,y)` into `f(x,y; kwargs....)`
408+
"""
397409
function _with_kwargs_expr(call_expr::Expr, kwargs)
398410
@assert isexpr(call_expr, :call)
399411
return Expr(
@@ -584,7 +596,9 @@ function _isvararg(expr::Expr)
584596
end
585597

586598
"""
587-
splits the first arg of the `call` expression into an expression to use in the signature
599+
_split_primal_name(primal_name)
600+
601+
Splits the first arg of the `call` expression into an expression to use in the signature
588602
and one to use for calling that function
589603
"""
590604
function _split_primal_name(primal_name)
@@ -604,15 +618,23 @@ function _split_primal_name(primal_name)
604618
end
605619
end
606620

607-
"turn both `a` and `a::S` into `a`"
621+
"""
622+
_unconstrain(a)
623+
624+
Turn both `a` and `a::S` into `a`
625+
"""
608626
_unconstrain(arg::Symbol) = arg
609627
function _unconstrain(arg::Expr)
610628
Meta.isexpr(arg, :(::), 2) && return arg.args[1] # drop constraint.
611629
Meta.isexpr(arg, :(...), 1) && return _unconstrain(arg.args[1])
612630
return error("malformed arguments: $arg")
613631
end
614632

615-
"turn both `a` and `::constraint` into `a::constraint` etc"
633+
"""
634+
_constrain_and_name(arg::Expr, _)
635+
636+
Turn both `a` and `::constraint` into `a::constraint` etc
637+
"""
616638
function _constrain_and_name(arg::Expr, _)
617639
Meta.isexpr(arg, :(::), 2) && return arg # it is already fine.
618640
Meta.isexpr(arg, :(::), 1) && return Expr(:(::), gensym(), arg.args[1]) # add name

src/tangent_types/abstract_tangent.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#####
44

55
"""
6+
AbstractTangent
7+
68
The subtypes of `AbstractTangent` define a custom \"algebra\" for chain
79
rule evaluation that attempts to factor various features like complex derivative
810
support, broadcast fusion, zero-elision, etc. into nicely separated parts.
@@ -40,4 +42,4 @@ Base.:+(x::AbstractTangent) = x
4042
@inline Base.conj(x::AbstractTangent) = x
4143

4244
Base.:/(x::AbstractTangent, y) = x * inv(y)
43-
Base.:\(x, y::AbstractTangent) = inv(x) * y
45+
Base.:\(x, y::AbstractTangent) = inv(x) * y

src/tangent_types/thunks.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Base.transpose(x::AbstractThunk) = @thunk(transpose(unthunk(x)))
162162

163163
"""
164164
Thunk(()->v)
165+
165166
A thunk is a deferred computation.
166167
It wraps a zero argument closure that when invoked returns a tangent.
167168
`@thunk(v)` is a macro that expands into `Thunk(()->v)`.

0 commit comments

Comments
 (0)