Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework docstrings #206

Merged
merged 13 commits into from Jan 23, 2022
Merged

Rework docstrings #206

merged 13 commits into from Jan 23, 2022

Conversation

t-bltg
Copy link
Member

@t-bltg t-bltg commented Jan 19, 2022

This PR automates docstring generation for arguments, function signatures, and README.md. Fix #45 ?

Rationale:

  • lots of arguments are duplicated across interfaces, with very similar signatures.
  • by automating this we can check descriptions: should start with a lowercase letter, sentences should end with a dot, ...
  • removing about 200+ lines of docstring code (with duplicates) for the same result.
  • simplifies maintenance for changes ( auto-generated README.md (default keywords), and gen_imgs.jl file for updating the examples).

The auto-generated README.md can be seen here, it should be rendered close to the existing one. It didn't want to pull in Documenter.jl, I'm just using Markdown from the stdlib to generate it dynamically.

Other changes:

  • simplify sentences by aiming single phrases, and reduce string lengths (for synthetic display in REPL).
  • follow Markdown syntax, as advised in Julia's documentation.
  • unifies func(args..., kwargs...) syntax.
  • transform z -> A in heatmap.jl, sinceA reflects a matrix structure by convention.

I've carefully inspected the results of help?> <function> where function is scatterplot, Plot, barplot, heatmap, ... against master and this is either equivalent of way better structured, since the arguments now follow a fixed order. We can fine tune each function arguments by giving desc, add, or remove keywords for the added arguments or signature functions.

  • generate descriptions
  • generate signatures
  • generate README.md automatically
  • generate examples automatically

I'm guessing that the runtime generation of docstrings only affects precompilation of Unicodeplots and not load time, but I'm not sure of that.

Unexpected, and this looks bad:
PR

julia> @time using UnicodePlots
  1.353077 seconds (3.25 M allocations: 231.825 MiB, 5.12% compilation time)

master

julia> @time using UnicodePlots
  0.395560 seconds (701.22 k allocations: 41.487 MiB, 17.54% compilation time)

@johnnychen94, do you have any obvious idea why this happens ?

EDIT: sorry for the noise, the increased load time was just the effect of adding Contour dependency and thus loading StaticArrays.

@t-bltg t-bltg force-pushed the docstring branch 3 times, most recently from af68f85 to 1b84241 Compare January 19, 2022 16:59
@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2022

Codecov Report

Merging #206 (42f5f06) into master (d4a63d2) will increase coverage by 0.00%.
The diff coverage is 96.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #206   +/-   ##
=======================================
  Coverage   99.57%   99.58%           
=======================================
  Files          24       25    +1     
  Lines        1180     1200   +20     
=======================================
+ Hits         1175     1195   +20     
  Misses          5        5           
Impacted Files Coverage Δ
src/canvas/lookupcanvas.jl 100.00% <ø> (ø)
src/colormaps.jl 100.00% <ø> (ø)
src/common.jl 100.00% <ø> (ø)
src/interface/barplot.jl 100.00% <ø> (ø)
src/interface/boxplot.jl 100.00% <ø> (ø)
src/interface/contourplot.jl 100.00% <ø> (+4.76%) ⬆️
src/interface/densityplot.jl 100.00% <ø> (ø)
src/interface/histogram.jl 100.00% <ø> (ø)
src/interface/lineplot.jl 97.10% <ø> (ø)
src/interface/scatterplot.jl 100.00% <ø> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4a63d2...42f5f06. Read the comment docs.

@t-bltg t-bltg force-pushed the docstring branch 2 times, most recently from 285d9c9 to df84c70 Compare January 20, 2022 15:51
@t-bltg t-bltg force-pushed the docstring branch 13 times, most recently from f6441f4 to ac8d5fc Compare January 21, 2022 17:17
@t-bltg t-bltg force-pushed the docstring branch 9 times, most recently from 5c3907e to 4a2b1eb Compare January 21, 2022 20:07
@t-bltg
Copy link
Member Author

t-bltg commented Jan 21, 2022

@johnnychen94, just to let you know that I think the PR is ready for review (nothing urgent though 😉 )

Copy link
Collaborator

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

src/interface/barplot.jl Show resolved Hide resolved
docs/generate_docs.jl Outdated Show resolved Hide resolved
t-bltg and others added 2 commits January 23, 2022 07:49
@t-bltg t-bltg force-pushed the docstring branch 3 times, most recently from 7d6148d to 776b1a2 Compare January 23, 2022 09:45
@t-bltg t-bltg merged commit cbb5bf8 into JuliaPlots:master Jan 23, 2022
@t-bltg t-bltg deleted the docstring branch January 23, 2022 09:59
@t-bltg t-bltg mentioned this pull request Jan 23, 2022
@t-bltg t-bltg mentioned this pull request Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve documentation
3 participants