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

If module is missing a docstring show readme if available #39093

Merged

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jan 4, 2021

(re)enables printing of readme's, if the module is missing a docstring. (supposedly this used to happen in some 0.x versions)

Recursively climbs up the path to the root package directory looking for readmes, in case a specific nested module has a dedicated readme at that directory level.

help?> LLVM_full_jll
search: LLVM_full_jll

  No docstring found for module LLVM_full_jll.

  Displaying the contents of /Users/ian/.julia/packages/LLVM_full_jll/YJHoG/README.md:

  LLVM_full_jll.jl (v11.0.0+9)
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  This is an autogenerated package constructed using BinaryBuilder.jl (https://github.com/JuliaPackaging/BinaryBuilder.jl). The originating
  build_tarballs.jl
  (https://github.com/JuliaPackaging/Yggdrasil/blob/19767c85345c2f81b7451344b87cc295dc5d8ac3/L/LLVM/LLVM_full@11.0.0/build_tarballs.jl) script can be
  found on Yggdrasil (https://github.com/JuliaPackaging/Yggdrasil/), the community build tree. If you have any issue, please report it to the Yggdrasil
  bug tracker (https://github.com/JuliaPackaging/Yggdrasil/issues).

  For more details about JLL packages and how to use them, see BinaryBuilder.jl documentation
  (https://juliapackaging.github.io/BinaryBuilder.jl/dev/jll/).

  Sources
  =========

  The tarballs for LLVM_full_jll.jl have been built from these sources:

    •  git repository: https://github.com/llvm/llvm-project.git (revision: 176249bd6732a8044d457092ed932768724a6f06)

    •  files in directory, relative to originating build_tarballs.jl: ./bundled
       (https://github.com/JuliaPackaging/Yggdrasil/tree/19767c85345c2f81b7451344b87cc295dc5d8ac3/L/LLVM/LLVM_full@11.0.0/bundled)

  Platforms
  ===========

  LLVM_full_jll.jl is available for the following platforms:

    •  macOS aarch64 (aarch64-apple-darwin)

    •  Linux aarch64 {cxxstring_abi=cxx03, libc=glibc} (aarch64-linux-gnu-cxx03)

    •  Linux aarch64 {cxxstring_abi=cxx11, libc=glibc} (aarch64-linux-gnu-cxx11)

    •  Linux aarch64 {cxxstring_abi=cxx03, libc=musl} (aarch64-linux-musl-cxx03)

    •  Linux aarch64 {cxxstring_abi=cxx11, libc=musl} (aarch64-linux-musl-cxx11)

    •  Linux armv6l {call_abi=eabihf, cxxstring_abi=cxx03, libc=glibc} (armv6l-linux-gnueabihf-cxx03)

    •  Linux armv6l {call_abi=eabihf, cxxstring_abi=cxx11, libc=glibc} (armv6l-linux-gnueabihf-cxx11)

    •  Linux armv6l {call_abi=eabihf, cxxstring_abi=cxx03, libc=musl} (armv6l-linux-musleabihf-cxx03)

    •  Linux armv6l {call_abi=eabihf, cxxstring_abi=cxx11, libc=musl} (armv6l-linux-musleabihf-cxx11)

    •  Linux armv7l {call_abi=eabihf, cxxstring_abi=cxx03, libc=glibc} (armv7l-linux-gnueabihf-cxx03)

    •  Linux armv7l {call_abi=eabihf, cxxstring_abi=cxx11, libc=glibc} (armv7l-linux-gnueabihf-cxx11)

    •  Linux armv7l {call_abi=eabihf, cxxstring_abi=cxx03, libc=musl} (armv7l-linux-musleabihf-cxx03)

    •  Linux armv7l {call_abi=eabihf, cxxstring_abi=cxx11, libc=musl} (armv7l-linux-musleabihf-cxx11)

    •  Linux i686 {cxxstring_abi=cxx03, libc=glibc} (i686-linux-gnu-cxx03)

    •  Linux i686 {cxxstring_abi=cxx11, libc=glibc} (i686-linux-gnu-cxx11)

    •  Linux i686 {cxxstring_abi=cxx03, libc=musl} (i686-linux-musl-cxx03)

    •  Linux i686 {cxxstring_abi=cxx11, libc=musl} (i686-linux-musl-cxx11)

    •  Windows i686 {cxxstring_abi=cxx03} (i686-w64-mingw32-cxx03)

    •  Windows i686 {cxxstring_abi=cxx11} (i686-w64-mingw32-cxx11)

    •  Linux powerpc64le {cxxstring_abi=cxx03, libc=glibc} (powerpc64le-linux-gnu-cxx03)

    •  Linux powerpc64le {cxxstring_abi=cxx11, libc=glibc} (powerpc64le-linux-gnu-cxx11)

    •  macOS x86_64 (x86_64-apple-darwin)

    •  Linux x86_64 {cxxstring_abi=cxx03, libc=glibc} (x86_64-linux-gnu-cxx03)

    •  Linux x86_64 {cxxstring_abi=cxx11, libc=glibc} (x86_64-linux-gnu-cxx11)

    •  Linux x86_64 {cxxstring_abi=cxx03, libc=musl} (x86_64-linux-musl-cxx03)

    •  Linux x86_64 {cxxstring_abi=cxx11, libc=musl} (x86_64-linux-musl-cxx11)

    •  FreeBSD x86_64 (x86_64-unknown-freebsd)

    •  Windows x86_64 {cxxstring_abi=cxx03} (x86_64-w64-mingw32-cxx03)

    •  Windows x86_64 {cxxstring_abi=cxx11} (x86_64-w64-mingw32-cxx11)

  Products
  ==========

  The code bindings within this package are autogenerated from the following Products:

    •  ExecutableProduct: clang

    •  LibraryProduct: libclang

    •  LibraryProduct: libllvm

    •  LibraryProduct: liblto

    •  ExecutableProduct: llc

    •  ExecutableProduct: llvm_config

    •  ExecutableProduct: llvm_mca

    •  ExecutableProduct: opt

@DilumAluthge
Copy link
Member

It would be nice to open either an editor or a pager if the README is long.

@DilumAluthge
Copy link
Member

Or, at the very least, show only up to the the first N characters of the README, for a suitable choice of N.

@IanButterworth IanButterworth force-pushed the ib/module_docstring_from_readme branch from f3bdef3 to fc03a94 Compare January 4, 2021 20:55
@IanButterworth
Copy link
Member Author

It would be nice to open either an editor or a pager if the README is long.

I think figuring out opening another editor/viewer would be hard to get the UX right across all the different front ends

Or, at the very least, show only up to the the first N characters of the README, for a suitable choice of N.

Is the annoyance of having too much text print greater than the possible annoyance of the text being cut off just before the bit you need? Perhaps a line limit makes sense, but I'd make it quite large. Large enough to show the entire example above, at least

@DilumAluthge
Copy link
Member

Perhaps a line limit makes sense, but I'd make it quite large. Large enough to show the entire example above, at least

Yeah you can definitely make it really large.

@DilumAluthge
Copy link
Member

DilumAluthge commented Jan 5, 2021

I think figuring out opening another editor/viewer would be hard to get the UX right across all the different front ends

Could we re-use the functionally of @edit?

@oxinabox
Copy link
Contributor

oxinabox commented Jan 5, 2021

It would be nice to open either an editor or a pager if the README is long.

Lets leave this for another discussion.
This same problem exists for docstrings in general.
So that solution needs to be broader than for this PR.
Its a bigger discussion and adding such functionality in this PR would make this PR be doing two things, which would make it a bad PR.

For this PR, I think we should just show the whole thing; or with some very loose cap on number of lines like it currently has.
A module docstring that is too long to read is no worse than no docstring at all.
So this PR is a net win already.

@mcabbott
Copy link
Contributor

mcabbott commented Jan 5, 2021

Could this hook into the # Extended help story with ?? perhaps?

While docstrings are written with the intention of being used like this, some readme files are pretty long, written assuming you have a browser.

Copy link
Contributor

@oxinabox oxinabox left a comment

Choose a reason for hiding this comment

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

This is great stuff

stdlib/REPL/src/docview.jl Show resolved Hide resolved
stdlib/REPL/src/docview.jl Show resolved Hide resolved
stdlib/REPL/src/docview.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/docview.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/docview.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/docview.jl Show resolved Hide resolved
stdlib/REPL/src/docview.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/docview.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/docview.jl Outdated Show resolved Hide resolved
@IanButterworth
Copy link
Member Author

@oxinabox identified a bug in Markdown interpretation #39103. Until that's fixed, the linebreaks here are perhaps the best we can do

@mgkuhn
Copy link
Contributor

mgkuhn commented Jan 5, 2021

I would rather like to see instead some mechanism to nudge package authors into providing a proper introductory docstring for each module, e.g. by running a test for the presence of such docstrings at package registration, or Documenter.jl issuing a warning about the absence of at least one module docstring in the documentation. This patch might delay, rather than encourage, the more ubiquitous presence of module docstrings.

README.md files could focus on information for people who have not yet downloaded and installed the module, and therefore their content would be somewhat more orthogonal to module docstrings.

@IanButterworth
Copy link
Member Author

mechanism to nudge package authors into providing a proper introductory docstring for each module, e.g. by running a test for the presence of such docstrings at package registration, or Documenter.jl issuing a warning about the absence of at least one module docstring in the documentation

Yeah, module docstrings are best. I don't think it's an either/or though, implementing what you suggest as well as this PR could be a fair way forward

@IanButterworth
Copy link
Member Author

First info now prints on a single line

help?> LLVM_full_jll
search: LLVM_full_jll

  No docstring found for module LLVM_full_jll. Displaying the contents of /Users/ian/.julia/packages/LLVM_full_jll/YJHoG/README.md:

  LLVM_full_jll.jl (v11.0.0+9)
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

@aviks
Copy link
Member

aviks commented Jan 5, 2021

How would this behave for packages added to custom sysimgs?

@IanButterworth
Copy link
Member Author

IanButterworth commented Jan 5, 2021

Good point. I added handling if pathof(m::Module) returns a path that doesn't exist. In that case now, no readme would be found gracefully

@IanButterworth
Copy link
Member Author

@StefanKarpinski Just a bump for review 🙏🏻

@IanButterworth
Copy link
Member Author

Updated given exported names are now shown on master if no module docstring exists:

help?> DifferentialEquations
search: DifferentialEquations

  No docstring found for module DifferentialEquations.

  Exported names
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  @derivatives, @ode_def, @ode_def_all, @ode_def_bare, @parameters, @register, @variables, AB3, AB4, AB5, ABDF2, ABM32, ABM43, ABM54, AN5, AbstractAnalyticalProblem, AbstractDiffEqArray,
  AbstractMultiScaleArray, AbstractMultiScaleArrayHead, AbstractMultiScaleArrayLeaf, AbstractVectorOfArray, AffineDiffEqOperator, AitkenNeville, AnalyticalProblem, Anas5, ArrayPartition,
  AutoAbstol, AutoDP5, AutoSOSRA2, AutoSOSRI2, AutoSwitch, AutoTsit5, AutoVern6, AutoVern7, AutoVern8, AutoVern9, BAOAB, BS3, BS5, BVProblem, BipartiteGraph, BlackScholesProblem,
  BoundaryValueDiffEq, BoxWedgeTail, BoxWedgeTail!, BracketData, BrownFullBasicInit, BrownianBridge, BrownianBridge!, CFNLIRK3, CFRLDDRK64, CG2, CG3, CKLLSRK43_2, CKLLSRK54_3C,
  ... (manually truncated)

  Displaying contents of readme found at /Users/ian/.julia/packages/DifferentialEquations/HSWeG/README.md
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  DifferentialEquations.jl
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  (Image: Join the chat at https://gitter.im/JuliaDiffEq/Lobby) (https://gitter.im/JuliaDiffEq/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) (Image:
  Build Status) (https://github.com/SciML/DifferentialEquations.jl/actions?query=workflow%3ACI) (Image: Stable) (http://diffeq.sciml.ai/stable/) (Image: Dev) (http://diffeq.sciml.ai/dev/)
  (Image: DOI) (https://zenodo.org/badge/latestdoi/58516043)

  This is a suite for numerically solving differential equations written in Julia and available for use in Julia, Python, and R. The purpose of this package is to supply efficient Julia
  implementations of solvers for various differential equations. Equations within the realm of this package include:

    •  Discrete equations (function maps, discrete stochastic (Gillespie/Markov) simulations)

    •  Ordinary differential equations (ODEs)

    •  Split and Partitioned ODEs (Symplectic integrators, IMEX Methods)

    •  Stochastic ordinary differential equations (SODEs or SDEs)

    •  Stochastic differential-algebraic equations (SDAEs)

    •  Random differential equations (RODEs or RDEs)

    •  Differential algebraic equations (DAEs)

    •  Delay differential equations (DDEs)

    •  Neutral, retarded, and algebraic delay differential equations (NDDEs, RDDEs, and DDAEs)

    •  Stochastic delay differential equations (SDDEs)

    •  Experimental support for stochastic neutral, retarded, and algebraic delay differential equations (SNDDEs, SRDDEs, and SDDAEs)

    •  Mixed discrete and continuous equations (Hybrid Equations, Jump Diffusions)

    •  (Stochastic) partial differential equations ((S)PDEs) (with both finite difference and finite element methods)
... (manually truncated)

compared to 1.6.0

help?> DifferentialEquations
search: DifferentialEquations

  No documentation found.

  No docstring found for module DifferentialEquations.

@IanButterworth IanButterworth force-pushed the ib/module_docstring_from_readme branch from 446d9dc to eaf307d Compare April 6, 2021 21:20
@IanButterworth IanButterworth changed the title Show readme if available, if module is missing a docstring If module is missing a docstring show readme if available Apr 8, 2021
@IanButterworth IanButterworth merged commit 549380d into JuliaLang:master Apr 8, 2021
@IanButterworth IanButterworth deleted the ib/module_docstring_from_readme branch April 8, 2021 02:13
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
…39093)

* print available readme if no docstring for module

* tweak search & print

* handle pathless modules

* limit readme print to first 200 lines

* review changes

* print message on single line

* handle modules in sysimage that are missing src files

* tweak formatting

* fix docstring test
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request May 9, 2021
…39093)

* print available readme if no docstring for module

* tweak search & print

* handle pathless modules

* limit readme print to first 200 lines

* review changes

* print message on single line

* handle modules in sysimage that are missing src files

* tweak formatting

* fix docstring test
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
…39093)

* print available readme if no docstring for module

* tweak search & print

* handle pathless modules

* limit readme print to first 200 lines

* review changes

* print message on single line

* handle modules in sysimage that are missing src files

* tweak formatting

* fix docstring test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants