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
Prev Previous commit
Next Next commit
Merge branch 'master' into ib/module_docstring_from_readme
  • Loading branch information
IanButterworth authored Apr 4, 2021
commit 557565d383c8b9ce46aaf21403eec68ed31a495b
17 changes: 14 additions & 3 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,28 @@ function find_readme(m::Module)::Union{String, Nothing}
end
function summarize(io::IO, m::Module, binding::Binding; nlines::Int = 200)
readme_path = find_readme(m)
if isnothing(readme_path)
println(io, "No docstring or readme file found for module `$m`.\n")
else
println(io, "No docstring found for module `$m`.")
end
exports = filter!(!=(nameof(m)), names(m))
if isempty(exports)
println(io, "Module does not export any names.")
else
println(io, "# Exported names:")
print(io, " `")
join(io, exports, "`, `")
println(io, "`")
end
if !isnothing(readme_path)
print(io, "No docstring found for module `$m`.")
readme_lines = readlines(readme_path)
isempty(readme_lines) && return # don't say we are going to print empty file
println(io, " Displaying the contents of `$(readme_path)`:\n\n")
for line in first(readme_lines, nlines)
println(io, line)
end
length(readme_lines) > nlines && println(io, "\n[output truncated to first $nlines lines]")
else
println(io, "No docstring or readme file found for module `$m`.\n")
end
end

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.