Documenter.jl icon indicating copy to clipboard operation
Documenter.jl copied to clipboard

[review]: sub TOC on the right side of the page

Open rmNULL opened this issue 4 years ago • 3 comments

Prototyping for #1688. All of the changes are still in development stage.

Will open for review once i think its ready.

rmNULL avatar Oct 17 '21 12:10 rmNULL

Hi, sorry about keeping this PR on hold.

The implementation only does bare bone styling in the hopes of getting the functionality working first. I'm not quite sure about the way i've implemented. And there are issues which i would like feedback on

conflicting/confusing scenario

#1638717639-window In this case, the left sidebar TOC already has the links, presenting it in the right side toc provides no benefits.

it somewhat works

#1638717466-window

Things are functional and work as expected. However as some of the links have types in them(e.g: #Documenter.Utilities.DOM.@tags-Tuple ) , the text can get quite lengthy, not sure what to do about this. We can strip the type or have a string representation that is different from the link. however this may create a confusion when same method exists with multiple types.

rmNULL avatar Dec 05 '21 15:12 rmNULL

@mortenpi Hi, Sorry about the direct mention. I can't continue the work further without inputs and i think this PR has been stuck in this wait state for a long time. I'm tagging in the hope of getting valuable feedback in soon future.

Thanks.

rmNULL avatar Feb 23 '22 16:02 rmNULL

Morten is on break, but I will find some time to play around with this.

However as some of the links have types in them(e.g: #Documenter.Utilities.DOM.@tags-Tuple ) , the text can get quite lengthy, not sure what to do about this. [...]

I think it should be stripped, and I think it is fine if there are then multiple similar links.

fredrikekre avatar Feb 23 '22 16:02 fredrikekre

Bump, need rebase.

Then I got an error:

=========================== @quietly: end of output ============================
ERROR: LoadError: @quietly hit an exception (KeyError):
KeyError: key Markdown.Header{1}(Any["Hidden 3"]) not found
Stacktrace:
  [1] getindex
    @ .\iddict.jl:108 [inlined]
  [2] #35
    @ E:\jl\Documenter.jl\src\html\HTMLWriter.jl:1097 [inlined]
  [3] iterate
    @ .\generator.jl:47 [inlined]
  [4] _collect(c::Vector{Any}, itr::Base.Generator{Vector{Any}, Documenter.HTMLWriter.var"#35#37"{Documenter.Page}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base .\array.jl:807
  [5] collect_similar(cont::Vector{Any}, itr::Base.Generator{Vector{Any}, Documenter.HTMLWriter.var"#35#37"{Documenter.Page}})
    @ Base .\array.jl:716
  [6] map(f::Function, A::Vector{Any})
    @ Base .\abstractarray.jl:2933
  [7] page_links(page::Documenter.Page)
    @ Documenter.HTMLWriter E:\jl\Documenter.jl\src\html\HTMLWriter.jl:1097
  [8] render_content_toc(ctx::Documenter.HTMLWriter.HTMLContext, navnode::Documenter.NavNode)
    @ Documenter.HTMLWriter E:\jl\Documenter.jl\src\html\HTMLWriter.jl:1104
  [9] render_article(ctx::Documenter.HTMLWriter.HTMLContext, navnode::Documenter.NavNode)
    @ Documenter.HTMLWriter E:\jl\Documenter.jl\src\html\HTMLWriter.jl:1395

Some local variables:

function page_links(page::Documenter.Page)
    mapping_links(x) = []
    mapping_links(mapping::Documenter.Anchors.Anchor) = [mapping.id]
    mapping_links(mapping::Documenter.DocsNode) = mapping_links(mapping.anchor)[1]
    mapping_links(mapping::Documenter.DocsNodes) = map(mapping_links, mapping.nodes)

    @show page.elements
    @show page.mapping
    mappings = map((element) -> page.mapping[element], page.elements)
    links = Iterators.flatten(map(mapping_links, mappings))
    return links
end
page.elements = Any[Markdown.Header{1}(Any["Hidden 3"])]
page.mapping = IdDict{Any, Any}()

inkydragon avatar Feb 23 '23 13:02 inkydragon

@inkydragon page.mapping is not really a thing anymore. It's probably easier to just re-implement the HTMLWriter.jl changes from scratch. The internal representation that gets fed to the writers changed quite a bit.

mortenpi avatar Mar 13 '23 08:03 mortenpi