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

Make sure we have LF line endings only. #791

Merged
merged 1 commit into from
Aug 14, 2018
Merged

Conversation

fredrikekre
Copy link
Member

fix #749, fix #790

@fredrikekre
Copy link
Member Author

@scls19fr can you try this branch? You can pkg> add Documenter#fe/fix-parsing from the Pkg REPL.

@fredrikekre
Copy link
Member Author

@Datseris maybe you can try this branch too, if you still can reproduce this problem.

@Datseris
Copy link
Contributor

Im on it.

@scls19fr
Copy link

LGTM. Thanks @fredrikekre for this fix

# Drop `skip` leading lines from the code block. Needed for deprecated `{docs}` syntax.
code = string(code, '\n')
code = last(split(code, '\n', limit = skip + 1))
# Check whether we have windows-style line endings.
offset = occursin("\n\r", code) ? 2 : 1
Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect the error was from this beeing "\n\r" and not "\r\n", but I figured we might as well just use "\n" internally.

Copy link
Member

Choose a reason for hiding this comment

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

The code here is not used when writing back things (like when fixing up doctests)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. That code kinda assumes \n anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

And also, this local code argument does not leak out of this parser function anyways.

@fredrikekre
Copy link
Member Author

Perfect, thanks for confirming.

@Datseris
Copy link
Contributor

Amazing @fredrikekre ! It works without any problems!

@@ -114,11 +114,11 @@ parsed from.
The keyword argument `skip = N` drops the leading `N` lines from the input string.
"""
function parseblock(code::AbstractString, doc, page; skip = 0, keywords = true)
# work only with LF line endings internally
code = replace(code, "\r\n" => "\n")
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, this could be dangerous if someone have "\r\n" in a string. Should revert this and let the Julia parser decide this kind of things instead.

@fredrikekre
Copy link
Member Author

@Datseris or @scls19fr sorry, but can you check the updated version too? pkg> up from the REPL if you still have this branch pkg> added, otherwise just add again as above.

@scls19fr
Copy link

It's broken on my side

@Datseris
Copy link
Contributor

Hm That's weird @scls19fr . @fredrikekre I can confirm that this is still LGTM on Windows 10. I am also testing it with a documentation that was problematic, i.e. was causing the problems of #749.

@scls19fr
Copy link

scls19fr commented Aug 13, 2018

Ok I will remove my .julia folder to double check

@scls19fr
Copy link

Sorry to say that... but

C:\Users\Admin-pc\.julia\dev\Documenter>julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-w64-mingw32

(v0.7) pkg> add Documenter#fe/fix-parsing
  Updating registry at `C:\Users\Admin-pc\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `https://github.com/JuliaDocs/Documenter.jl.git`
 Resolving package versions...
  Updating `C:\Users\Admin-pc\.julia\environments\v0.7\Project.toml`
 [no changes]
  Updating `C:\Users\Admin-pc\.julia\environments\v0.7\Manifest.toml`
 [no changes]

(v0.7) pkg> up
  Updating registry at `C:\Users\Admin-pc\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `https://github.com/JuliaDocs/Documenter.jl.git`
 Resolving package versions...
  Updating `C:\Users\Admin-pc\.julia\environments\v0.7\Project.toml`
 [no changes]
  Updating `C:\Users\Admin-pc\.julia\environments\v0.7\Manifest.toml`
 [no changes]

julia>

C:\Users\Admin-pc\.julia\dev\Documenter>cd ../DataStructures

C:\Users\Admin-pc\.julia\dev\DataStructures>cd docs

C:\Users\Admin-pc\.julia\dev\DataStructures\docs>julia make.jl
Documenter: setting up build directory.
ERROR: LoadError: IOError: stat: operation not permitted (EPERM)
Stacktrace:
 [1] stat(::String) at .\stat.jl:68
 [2] isdir at .\stat.jl:303 [inlined]
 [3] runner(::Type{Documenter.Builder.SetupBuildDirectory}, ::Documenter.Documents.Document) at C:\Users\Admin-pc\.julia\packages\Documenter\wDjsI\src\Builder.jl:91
 [4] dispatch(::Type{Documenter.Builder.DocumentPipeline}, ::Documenter.Documents.Document) at C:\Users\Admin-pc\.julia\packages\Documenter\wDjsI\src\Utilities\Selectors.jl:168
 [5] #2 at C:\Users\Admin-pc\.julia\packages\Documenter\wDjsI\src\Documenter.jl:206 [inlined]
 [6] cd(::getfield(Documenter, Symbol("##2#3")){Documenter.Documents.Document}, ::String) at .\file.jl:85
 [7] #makedocs#1 at C:\Users\Admin-pc\.julia\packages\Documenter\wDjsI\src\Documenter.jl:205 [inlined]
 [8] (::getfield(Documenter, Symbol("#kw##makedocs")))(::NamedTuple{(:format, :sitename, :pages, :modules),Tuple{Symbol,String,Array{String,1},Array{Module,1}}}, ::typeof(makedocs)) at .\none:0
 [9] top-level scope at none:0
 [10] include at .\boot.jl:317 [inlined]
 [11] include_relative(::Module, ::String) at .\loading.jl:1038
 [12] include(::Module, ::String) at .\sysimg.jl:29
 [13] exec_options(::Base.JLOptions) at .\client.jl:239
 [14] _start() at .\client.jl:432
in expression starting at C:\Users\Admin-pc\.julia\dev\DataStructures\docs\make.jl:5

C:\Users\Admin-pc\.julia\dev\DataStructures\docs>julia make.jl
Documenter: setting up build directory.
Documenter: expanding markdown templates.
 !! No docs found for 'find(m::SortedDict, k_)'. [src\sorted_containers.md]
 !! No docs found for 'similar(sc::SortedDict)'. [src\sorted_containers.md]
 !! No docs found for 'get(sd::SortedDict,k,v)'. [src\sorted_containers.md]
 !! No docs found for 'get!(sd::SortedDict,k,v)'. [src\sorted_containers.md]
WARNING: importing deprecated binding Base.Associative into DataStructures.
WARNING: Base.Associative is deprecated, use AbstractDict instead.
  likely near C:\Users\Admin-pc\.julia\dev\DataStructures\docs\make.jl:5
WARNING: Base.Associative is deprecated, use AbstractDict instead.
  likely near C:\Users\Admin-pc\.julia\dev\DataStructures\docs\make.jl:5
Documenter: building cross-references.
Documenter: running document checks.
 > checking for missing docstrings.
 !! 96 docstrings potentially missing:
 > running doctests.
 > checking footnote links.
Documenter: populating indices.
Documenter: rendering document.
Documenter: skipping docs deployment.
  You can set DOCUMENTER_DEBUG to "true" in Travis to see more information.

Browsing to file:///C:/Users/Admin-pc/.julia/dev/DataStructures/docs/build/default_dict.html and
I still have

julia> dd = DefaultDict{AbstractString, Vector{Int}}(Vector{Int})
DefaultDict{AbstractString,Array{Int64,1},DataType} with 0 entries

julia> p
┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0
ERROR: UndefVarError:  not defined

Maybe I did something wrong

Copy link
Member

@mortenpi mortenpi left a comment

Choose a reason for hiding this comment

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

LGTM. Should definitely be CRLF nor LFCR if we're looking for windows line endings.

@fredrikekre
Copy link
Member Author

@scls19fr do you mean that the previous version of this PR worked? It looks like you get different errors now.

@scls19fr
Copy link

This is because it's not the same part of page (with the minimal md file I mentioned #790 (comment) I get)

julia> dd = DefaultDict{AbstractString, Vector{Int}}(Vector{Int})
DefaultDict{AbstractString,Array{Int64,1},DataType} with 0 entries

julia> p
┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0
ERROR: UndefVarError:  not defined

julia> ush!(dd["A"], 1)
ERROR: UndefVarError: ush! not defined

julia> p
┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0
ERROR: UndefVarError:  not defined

julia> ush!(dd["B"], 2)
ERROR: UndefVarError: ush! not defined

julia> d
┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0
ERROR: UndefVarError:  not defined

julia> d
ERROR: UndefVarError: d not defined

I think the previous PR was working correctly.
Did you squash commits? Can remember what you changed

@Datseris
Copy link
Contributor

This may sound stupid, but I recall from Slack that add Package#somebranch always adds the master branch and one has to check out manually via git....?

@KristofferC
Copy link
Member

add Package#branch should get the correct branch, otherwise that is a bug.

@scls19fr
Copy link

This is probably the kind of issue I'm also facing.

C:\Users\Admin-pc\.julia\dev\Documenter>julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-w64-mingw32

(v0.7) pkg> add Documenter#fe/fix-parsing
  Updating registry at `C:\Users\Admin-pc\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `https://github.com/JuliaDocs/Documenter.jl.git`
 Resolving package versions...
  Updating `C:\Users\Admin-pc\.julia\environments\v0.7\Project.toml`
 [no changes]
  Updating `C:\Users\Admin-pc\.julia\environments\v0.7\Manifest.toml`
 [no changes]

(v0.7) pkg> ^C

julia> ^C

julia>

C:\Users\Admin-pc\.julia\dev\Documenter>git branch
* master

@fredrikekre
Copy link
Member Author

added branches does not end up in dev

@Datseris
Copy link
Contributor

Datseris commented Aug 13, 2018

add Package#branch should get the correct branch, otherwise that is a bug.

It does, just tested it as well. Sorry for the off-topic comment!

@scls19fr
Copy link

scls19fr commented Aug 13, 2018

How can I check that I'm running the "right" Documenter (ie from fe/fix-parsing branch)?

@fredrikekre
Copy link
Member Author

Ok, found a simple testcase that still fails on this branch. Will ping you when I have a new version that you can try.

@fredrikekre
Copy link
Member Author

Okay, @Datseris and @scls19fr feel free to test the new version.

@fredrikekre fredrikekre merged commit fe8a644 into master Aug 14, 2018
@fredrikekre fredrikekre deleted the fe/fix-parsing branch August 14, 2018 04:44
@scls19fr
Copy link

scls19fr commented Aug 14, 2018

After you merged to master, I did

Pkg.rm("Documenter")
Pkg.develop("Documenter")

but I still facing #790

@KristofferC
Copy link
Member

You might have to pull the newest version manually, there is a bug where develop fails to get the latest version.

@Datseris
Copy link
Contributor

I can still confirm that on the current master this works for me.

@scls19fr
Copy link

Under Mac OS X now

$ cd ~/.julia/dev/Documenter
$ git pull
$ cd ~/.julia/dev/DataStructures/docs
$ julia make.jl

Minimal md file mentioned in #790 (comment) saved with CRLF or LF as EOL still render badly

julia> dd = DefaultDict{AbstractString, Vector{Int}}(Vector{Int})
DefaultDict{AbstractString,Array{Int64,1},DataType} with 0 entries

┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0

julia> push!(dd["A"], 1)
1-element Array{Int64,1}:
 1

┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0

julia> push!(dd["B"], 2)
1-element Array{Int64,1}:
 2

┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0

julia> dd
DefaultDict{AbstractString,Array{Int64,1},DataType} with 2 entries:
  "B" => [2]
  "A" => [1]

@scls19fr
Copy link

Trying with an even simpler file

# Dict

```@repl
dd = Dict{AbstractString, Int}()

dd["A"] = 1

dd

(CRLF or LF)

rendered as

julia> dd = Dict{AbstractString, Int}()
Dict{AbstractString,Int64} with 0 entries

┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0

julia> dd["A"] = 1
1

┌ Warning: Deprecated syntax `underscores as an rvalue`.
└ @ none:0

julia> dd
Dict{AbstractString,Int64} with 1 entry:
  "A" => 1

mortenpi pushed a commit that referenced this pull request Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR: UndefVarError: not defined Totally weird parsing/unknown problem...
5 participants