# Some thoughts on improving basic function documentation

**URL:** <https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546>\
**Category:** General Usage\
**Tags:** documentation\
**Created:** [September 5, 2023, 3:18pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546 "2023-09-05T15:18:56Z")\
**Posts on this page:** 12\
**Page:** 3

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [September 10, 2023, 3:56am UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/41 "2023-09-10T03:56:15Z")

</div>

One of the examples does show this, but if you feel that it can be clearer then open an issue at  
[Issues · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues) with your exact proposed change (If you can, then a [pull request](https://github.com/JuliaLang/julia/pulls) would be better).

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [September 10, 2023, 7:48am UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/42 "2023-09-10T07:48:13Z")

</div>

Maybe by adding a comment to it like

```julia
julia> 7 > 3 > 1 # equivalent to 7 > 3 && 3 > 1
  true

```

---

<div class="post-metadata">

**Author:** ![VinodV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinodv/32/32733_2.png) [@VinodV](https://discourse.julialang.org/u/VinodV)\
**Post date:** [September 10, 2023, 9:00am UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/43 "2023-09-10T09:00:58Z")

</div>

This chaining is missing in the doc of `<`

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [September 10, 2023, 10:03am UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/44 "2023-09-10T10:03:53Z")

</div>

So it is, maybe should add a corresponding

```julia
julia> 1 < 3 < 7 # equivalent to 1 < 3 && 3 < 7
  true

```

---

<div class="post-metadata">

**Author:** ![VinodV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinodv/32/32733_2.png) [@VinodV](https://discourse.julialang.org/u/VinodV)\
**Post date:** [September 10, 2023, 3:04pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/45 "2023-09-10T15:04:51Z")

</div>

```julia
mutable struct Car
odometer::Float64
end
cars = [Car(rand(4)...) for _ in 1:5]
Base.isless(c1::Car,c2::Car) = c1.odometer < c2.odometer
findmin(cars)

```

The above code is really a Julia gem.[got from stackoverflow]. Why not it is included in the Julia doc of `isless`.

```julia
julia> isless([1,2],[1,3])
true

julia> isless([1,2],[1,-1])
false

```

This can also be included I think

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [September 10, 2023, 4:37pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/46 "2023-09-10T16:37:23Z")

</div>

> [@VinodV](#):
>
> ```julia
> cars = [Car(rand(4)...) for _ in 1:5]
> 
> ```

Doesn’t work, maybe

```julia
cars = [Car(rand()) for _ in 1:5]

```

but I would prefer

```julia
cars = Car.(rand(5))

```

The docs state that if you define `Base.isless` then you should also define `Base.isequal`, so make sure to do that to make the example 100% correct.

> [@VinodV](#):
>
> ```julia
> julia> isless([1,2],[1,3])
> true
> 
> julia> isless([1,2],[1,-1])
> false
> 
> ```
> 
> This can also be included I think

Good idea and I think that it could even clarify things an extra amount with a third example: `isless([0,2],[1,-1])`

I see that the 1.9 docstring for `isless(A::AbstractVector, B::AbstractVector)` uses capitals for the parameter names which is against Julia naming convention, so this should also be changed to `isless(a::AbstractVector, b::AbstractVector)`

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [October 20, 2024, 3:27pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/47 "2024-10-20T15:27:52Z")

</div>

> [@tecosaur](#):
>
> I really need to make my WIP `CheckDoc.jl` public, with the various kinks… documentation of error types that may be `throw`n is one of the checks I’ve implemented.
> 
> Perhaps if it’s public I could get help in solving some of the difficulties I’m having that have been (mentally) blocking me from making it public 😛

**Update:** [GitHub - tecosaur/CheckDoc.jl: Documentation linting](https://github.com/tecosaur/CheckDoc.jl/) is now public 😀 (though currently unregistered).

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 20, 2024, 3:56pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/48 "2024-10-20T15:56:54Z")

</div>

Reported an issue:

> <https://github.com/tecosaur/CheckDoc.jl/issues/6>
>
> Reproducer:
> 
> \`\`\`julia
> """
> ExampleModule
> 
> An example module.
> """
> bare…module ExampleModule
> baremodule Implementation
> export name
> function name end
> end
> 
> export public\_name
> 
> """
> public\_name
> 
> Call to do stuff.
> """
> const public\_name = Implementation.name
> end
> 
> using CheckDoc: checkdocs
> checkdocs(ExampleModule)
> \`\`\`
> 
> Output:
> 
> \`\`\`none
> ◀▶ Report on 3 entities in Main.ExampleModule ━ found 2 possible issues
> ════════════════════════════════════════════════════════════════════════
> ╭─● Error
> │ ┌ VariablesHaveDoc: Should be documented
> │ └ 1. Implementation @ unknown (within nothing)
> │ ┌ PublicHaveDoc: Should be documented
> ╰ └ 2. Implementation.name @ unknown (within nothing)
> \`\`\`
> 
> The \`checkdocs\` function says that:
> \* \`Implementation\` "should be documented", even though it's an internal implementation detail
> \* \`Implementation.name\` "should be documented", even though it's an implementation detail (because \`Implementation\` isn't public)
> 
> Also, the \`@ unknown (within nothing)\` parts in the output are confusing and suspicious.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [October 21, 2024, 12:20pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/49 "2024-10-21T12:20:58Z")

</div>

I am also following up here to say that the Documentation tutorial is up on JuliaLang youtube channel and it indeed tries to establish a standard form for docstrings:

[![](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d97b959970b10995cb806bc86d10f66feb9dc41.jpeg "Writing and Maintaining Exceptional Documentation | JuliaCon 2024 Workshop") ](https://www.youtube.com/watch?v=ZDQ28X3mGSo&t=1448)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 21, 2024, 2:04pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/50 "2024-10-21T14:04:31Z")

</div>

I vaguely remember having seen admonitions in the Julia manual that Description, Arguments, etc. should be level-one headings. I think GD uses second-level. Are there any arguments for one over the other?

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [October 21, 2024, 2:07pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/51 "2024-10-21T14:07:50Z")

</div>

I don’t know what GD means, but I use level 2 headings. My reason was that in the rendered pages in Documenter’s HTML output, which is the default setup for most packages, level 1 headers in docstrings were very large. I preferred them just a bit toned down so I went with level 2 markdown headers in docstrings.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 21, 2024, 2:08pm UTC](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546/52 "2024-10-21T14:08:36Z")

</div>

GD is you 😉

[Previous page](https://discourse.julialang.org/t/some-thoughts-on-improving-basic-function-documentation/103546.md?page=2)
