JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.43k stars 5.45k forks source link

Documenting an assignment (variable) #25529

Open hpoit opened 6 years ago

hpoit commented 6 years ago

When I run Weiqi.jl I get image where line 522 of board.jl doesn't exist: https://github.com/hpoit/Weiqi.jl/blob/master/src/board.jl

The real issue was trying to document "Test board" for an assignment https://github.com/hpoit/Weiqi.jl/blob/master/src/board.jl#L28

hpoit commented 6 years ago

David got something similar image

StefanKarpinski commented 6 years ago

What is the actionable change you'd like to see here?

fredrikekre commented 6 years ago

dup of #24468? in that case fixed by #24512?

hpoit commented 6 years ago

From the error message I had no idea what I was incorrectly doing. Your call.

KristofferC commented 6 years ago

I agree that the error message here is not good at all.

vtjnash commented 7 months ago

The line number is fixed, but the error message with Binding is still not great:

julia> @doc "bad doc" Int.afield
ERROR: MethodError: no method matching Base.Docs.Binding(::Type{Int64}, ::Symbol)

Closest candidates are:
  Base.Docs.Binding(!Matched::Module, ::Symbol)
   @ Base docs/bindings.jl:9

Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

help?> Int.name.flags
ERROR: MethodError: no method matching Base.Docs.Binding(::Core.TypeName, ::Symbol)

Closest candidates are:
  Base.Docs.Binding(!Matched::Module, ::Symbol)
   @ Base docs/bindings.jl:9

Stacktrace:
 [1] (::REPL.Logged{DataType})(::Core.TypeName, ::Vararg{Any})
   @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/docview.jl:172
 [2] top-level scope
   @ ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/docview.jl:607

help?> Int.name
ERROR: KeyError: key :fields not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, Any}, key::Symbol)
   @ Base ./dict.jl:515
 [2] fielddoc(binding::Base.Docs.Binding, field::Symbol)
   @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/docview.jl:629
 [3] fielddoc(object::Type, field::Symbol)
   @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/docview.jl:644
 [4] top-level scope
   @ ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/docview.jl:605

We should perhaps add a fallback constructor for Binding that throws a more specific error, rather than failing in these obscure ways.