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

Updating docstrings for modules concatenates #29432

Closed
timholy opened this issue Sep 29, 2018 · 0 comments
Closed

Updating docstrings for modules concatenates #29432

timholy opened this issue Sep 29, 2018 · 0 comments
Labels
docsystem The documentation building system

Comments

@timholy
Copy link
Sponsor Member

timholy commented Sep 29, 2018

When updating a module docstring, the old one is retained, which is probably not the behavior we want. Demo:

julia> "Outer docstring" module Outer
       "Inner docstring" module Inner
       "Inner2 docstring" module Inner2
       end
       end
       end
Main.Outer

help?> Outer
search: Outer count_zeros RoundToZero OutOfMemoryError countlines count_ones RoundNearestTiesUp RoundNearestTiesAway

  Outer docstring

help?> Outer.Inner
  Inner docstring

help?> Outer.Inner.Inner2
  Inner2 docstring

julia> "New outer docstring" Outer
Outer

help?> Outer
search: Outer count_zeros RoundToZero OutOfMemoryError countlines count_ones RoundNearestTiesUp RoundNearestTiesAway

  Outer docstring

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  New outer docstring

I'm not sufficiently familiar with doc system to be efficient about this, but in case it helps, here's the start of a debugging session:

diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl
index d409eea9a6..b9650d7fd9 100644
--- a/base/docs/Docs.jl
+++ b/base/docs/Docs.jl
@@ -215,6 +215,7 @@ Adds a new docstring `str` to the docsystem of `__module__` for `binding` and si
 """
 function doc!(__module__::Module, b::Binding, str::DocStr, @nospecialize sig = Union{})
     initmeta(__module__)
+    @show __module__ b str sig meta(__module__)
     m = get!(meta(__module__), b, MultiDoc())
     if haskey(m.docs, sig)
         # We allow for docstrings to be updated, but print a warning since it is possible
julia> using Revise

julia> Revise.track(Base)

julia> "Outer docstring" module Outer
       "Inner docstring" module Inner
       "Inner2 docstring" module Inner2
       end
       end
       end
__module__ = Main.Outer.Inner.Inner2
b = Main.Outer.Inner.Inner2
str = Base.Docs.DocStr(svec("Inner2 docstring"), nothing, Dict{Symbol,Any}(:module=>Main.Outer.Inner.Inner2,:linenumber=>3,:path=>"REPL[3]"))
sig = Union{}
meta(__module__) = IdDict{Any,Any}()
__module__ = Main.Outer.Inner
b = Main.Outer.Inner
str = Base.Docs.DocStr(svec("Inner docstring"), nothing, Dict{Symbol,Any}(:module=>Main.Outer.Inner,:linenumber=>2,:path=>"REPL[3]"))
sig = Union{}
meta(__module__) = IdDict{Any,Any}()
__module__ = Main.Outer
b = Outer
str = Base.Docs.DocStr(svec("Outer docstring"), nothing, Dict{Symbol,Any}(:module=>Main.Outer,:linenumber=>1,:path=>"REPL[3]"))
sig = Union{}
meta(__module__) = IdDict{Any,Any}()
Main.Outer

help?> Outer
search: Outer count_zeros RoundToZero OutOfMemoryError countlines count_ones RoundNearestTiesUp RoundNearestTiesAway

  Outer docstring

help?> Outer.Inner
  Inner docstring

help?> Outer.Inner.Inner2
  Inner2 docstring

julia> "New outer docstring" Outer
__module__ = Main
b = Outer
str = Base.Docs.DocStr(svec("New outer docstring"), nothing, Dict{Symbol,Any}(:module=>Main,:linenumber=>1,:path=>"REPL[7]"))
sig = Union{}
meta(__module__) = IdDict{Any,Any}()
Outer

help?> Outer
search: Outer count_zeros RoundToZero OutOfMemoryError countlines count_ones RoundNearestTiesUp RoundNearestTiesAway

  Outer docstring

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  New outer docstring

julia> "New inner docstring" Outer.Inner
__module__ = Main
b = Main.Outer.Inner
str = Base.Docs.DocStr(svec("New inner docstring"), nothing, Dict{Symbol,Any}(:module=>Main,:linenumber=>1,:path=>"REPL[9]"))
sig = Union{}
meta(__module__) = IdDict{Any,Any}(Outer=>MultiDoc(Type[Union{}], IdDict{Any,Any}(Union{}=>DocStr(svec("New outer docstring"), New outer docstring
, Dict{Symbol,Any}(:typesig=>Union{},:module=>Main,:linenumber=>1,:binding=>Outer,:path=>"REPL[7]")))))
Main.Outer.Inner

help?> Outer.Inner
  Inner docstring

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  New inner docstring

julia> "This is foo" foo(x::Int) = 1
__module__ = Main
b = foo
str = Base.Docs.DocStr(svec("This is foo"), nothing, Dict{Symbol,Any}(:module=>Main,:linenumber=>1,:path=>"REPL[11]"))
sig = Tuple{Int64}
meta(__module__) = IdDict{Any,Any}(Outer=>MultiDoc(Type[Union{}], IdDict{Any,Any}(Union{}=>DocStr(svec("New outer docstring"), New outer docstring
, Dict{Symbol,Any}(:typesig=>Union{},:module=>Main,:linenumber=>1,:binding=>Outer,:path=>"REPL[7]")))),Main.Outer.Inner=>MultiDoc(Type[Union{}], IdDict{Any,Any}(Union{}=>DocStr(svec("New inner docstring"), New inner docstring
, Dict{Symbol,Any}(:typesig=>Union{},:module=>Main,:linenumber=>1,:binding=>Main.Outer.Inner,:path=>"REPL[9]")))))
foo

help?> foo
search: foo floor pointer_from_objref OverflowError RoundFromZero unsafe_copyto! functionloc StackOverflowError @functionloc OutOfMemoryError UndefKeywordError unsafe_pointer_to_objref

  This is foo

julia> "This is new foo" foo(x::Int) = 2
__module__ = Main
b = foo
str = Base.Docs.DocStr(svec("This is new foo"), nothing, Dict{Symbol,Any}(:module=>Main,:linenumber=>1,:path=>"REPL[13]"))
sig = Tuple{Int64}
meta(__module__) = IdDict{Any,Any}(Outer=>MultiDoc(Type[Union{}], IdDict{Any,Any}(Union{}=>DocStr(svec("New outer docstring"), New outer docstring
, Dict{Symbol,Any}(:typesig=>Union{},:module=>Main,:linenumber=>1,:binding=>Outer,:path=>"REPL[7]")))),foo=>MultiDoc(Type[Tuple{Int64}], IdDict{Any,Any}(Tuple{Int64}=>DocStr(svec("This is foo"), This is foo
, Dict{Symbol,Any}(:typesig=>Tuple{Int64},:module=>Main,:linenumber=>1,:binding=>foo,:path=>"REPL[11]")))),Main.Outer.Inner=>MultiDoc(Type[Union{}], IdDict{Any,Any}(Union{}=>DocStr(svec("New inner docstring"), New inner docstring
, Dict{Symbol,Any}(:typesig=>Union{},:module=>Main,:linenumber=>1,:binding=>Main.Outer.Inner,:path=>"REPL[9]")))))
foo

help?> foo
search: foo floor pointer_from_objref OverflowError RoundFromZero unsafe_copyto! functionloc StackOverflowError @functionloc OutOfMemoryError UndefKeywordError unsafe_pointer_to_objref

  This is new foo
@timholy timholy added the docsystem The documentation building system label Sep 29, 2018
timholy added a commit that referenced this issue Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docsystem The documentation building system
Projects
None yet
Development

No branches or pull requests

1 participant