tlienart / Xranklin.jl

Experimental repo for a refactoring of Franklin.jl
https://tlienart.github.io/Xranklin.jl
MIT License
40 stars 1 forks source link

Attempt to migrate a Franklin build #170

Open joa-quim opened 1 year ago

joa-quim commented 1 year ago

See https://github.com/tlienart/Franklin.jl/issues/989#issuecomment-1338128088 for initial story

Tried Xranklin but I'm having several errors. Maybe this one summarizes it. (same thing with Julia 1.7)

julia> import Pkg; Pkg.precompile()
  0 dependencies successfully precompiled in 1 seconds. 236 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

Xranklin [713c75ef-9fc9-4b05-94a9-213340da978e]

Error: Missing source file for Xranklin [713c75ef-9fc9-4b05-94a9-213340da978e
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types C:\programs\julia-1.9\share\julia\stdlib\v1.9\Pkg\src\Types.jl:68
 [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{String}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API C:\programs\julia-1.9\share\julia\stdlib\v1.9\Pkg\src\API.jl:1436
 [3] precompile
   @ C:\programs\julia-1.9\share\julia\stdlib\v1.9\Pkg\src\API.jl:1073 [inlined]
 [4] #precompile#217
   @ C:\programs\julia-1.9\share\julia\stdlib\v1.9\Pkg\src\API.jl:1072 [inlined]
 [5] precompile
   @ C:\programs\julia-1.9\share\julia\stdlib\v1.9\Pkg\src\API.jl:1072 [inlined]
 [6] precompile()
   @ Pkg.API C:\programs\julia-1.9\share\julia\stdlib\v1.9\Pkg\src\API.jl:1072
 [7] top-level scope
   @ REPL[6]:1

(GMTjl_doc_X) pkg> st
Status `C:\v\doc_t\GMTjl_doc_X\Project.toml`
  [1520ce14] AbstractTrees v0.4.3
  [8be319e6] Chain v0.5.0
  [35d6a980] ColorSchemes v3.20.0
  [c3611d14] ColorVectorSpace v0.9.9
  [5ae59095] Colors v0.12.8
  [e30172f5] Documenter v0.27.23
  [5789e2e9] FileIO v1.16.0
  [5752ebe1] GMT v0.43.2
  [708ec375] Gumbo v0.8.2
  [a09fc81d] ImageCore v0.9.4
  [82e4d734] ImageIO v0.6.6
  [6218d12a] ImageMagick v1.2.2
  [02fcd773] ImageTransformations v0.9.5
  [824d6782] JSServe v1.2.9
  [2bd173c7] NodeJS v1.3.0
  [08abe8d2] PrettyTables v2.2.2
  [f3b207a7] StatsPlots v0.15.4
  [713c75ef] Xranklin v0.10.79
joa-quim commented 1 year ago

And trying your suggestion

using Xranklin; serve(debug=true)

...
┌ Debug: Loading cache file C:\Users\joaqu\.julia\compiled\v1.9\ImageTransformations\Pfac4_LuoiV.ji for ImageTransformations [02fcd773-0e25-5acc-982a-7f6622650795]
└ @ Base loading.jl:900
ERROR: LoadError: UndefVarError: `@delay` not defined
Stacktrace:
 [1] top-level scope
   @ :0
 [2] eval
   @ .\boot.jl:370 [inlined]
 [3] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1522
 [4] include_string (repeats 2 times)
   @ .\loading.jl:1532 [inlined]
 [5] process_utils(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, utils::String)
   @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\process\config_utils.jl:161
 [6] process_utils(gc::Xranklin.GlobalContext{Xranklin.LocalContext})
   @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\process\config_utils.jl:192
 [7] serve(d::String; dir::String, folder::String, clear::Bool, final::Bool, single::Bool, eval::Bool, nocode::Bool, threads::Bool, use_threads::Bool, prepath::String, prefix::String, base_url_prefix::String, debug::Bool, cleanup::Bool, skip::Vector{String}, port::Int64, host::String, launch::Bool)
   @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\serve.jl:132
 [8] serve
   @ C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\serve.jl:54 [inlined]
 [9] top-level scope
   @ REPL[10]:1
in expression starting at string:162
in expression starting at string:162
tlienart commented 1 year ago

@delay is deprecated in Xranklin; so try to remove that from utils.jl.

For your first issue, can I just check that what you did is

] add https://github.com/tlienart/Xranklin.jl

?

the result from st in your first comment is weird (there's no release of Xranklin so it should not put a 0.10.79 in front of it, that's Franklin's latest release.

Also just in case, you should be working in a dedicated environment with Xranklin (so there shouldn't be both Franklin and Xranklin in your project).

joa-quim commented 1 year ago

OK, I found the mistake that explains the [713c75ef] Xranklin v0.10.79 line. In the Project.toml I only replaced Franklin by Xranklin but forgot to change the UUID too. But now it complain that Xranklin is not registered

julia> serve(debug=true)
  Activating project at `c:\v\doc_t\GMTjl_doc_X`
    Updating registry at `C:\Users\joaqu\.julia\registries\General.toml`
ERROR: expected package `Xranklin [558449b0]` to be registered
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\Types.jl:68
  [2] check_registered
    @ C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1090 [inlined]
  [3] up(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, level::Pkg.Types.UpgradeLevel; skip_writing_project::Bool)
    @ Pkg.Operations C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1263
  [4] up(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; level::Pkg.Types.UpgradeLevel, mode::Pkg.Types.PackageMode, update_registry::Bool, skip_writing_project::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\API.jl:333
  [5] #up#55
    @ C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\API.jl:154 [inlined]
  [6] instantiate(ctx::Pkg.Types.Context; manifest::Nothing, update_registry::Bool, verbose::Bool, platform::Base.BinaryPlatforms.Platform, allow_build::Bool, allow_autoprecomp::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\API.jl:1443
  [7] instantiate
    @ C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\API.jl:1422 [inlined]
  [8] #instantiate#276
    @ C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\API.jl:1418 [inlined]
  [9] instantiate
    @ C:\programs\julia-1.7\share\julia\stdlib\v1.7\Pkg\src\API.jl:1418 [inlined]
 [10] serve(d::String; dir::String, folder::String, clear::Bool, final::Bool, single::Bool, eval::Bool, nocode::Bool, threads::Bool, use_threads::Bool, prepath::String, prefix::String, base_url_prefix::String, debug::Bool, cleanup::Bool, skip::Vector{String}, port::Int64, host::String, launch::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\serve.jl:106
 [11] top-level scope
    @ REPL[4]:1
joa-quim commented 1 year ago

So I tried a trick: remove Xranklin from the Project.toml but Julia in it's best (incomprehensible error/stack trace)

serve(debug=true)

...
┌ Debug: � ... try_form_lxdef > \newcommand
└ @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\misc_utils.jl:105
┌ Debug: � ... try_form_lxdef > \newcommand
└ @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\misc_utils.jl:105
[ Info: ... [config.md] ✔ (δt = 27ms)

[ Info: � starting the full pass

ERROR: LoadError: syntax: invalid escape sequence
Stacktrace:
  [1] top-level scope
    @ string:4
  [2] eval
    @ .\boot.jl:373 [inlined]
  [3] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:1196
  [4] include_string (repeats 2 times)
    @ .\loading.jl:1206 [inlined]
  [5] modules_setup(c::Xranklin.LocalContext)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\code\modules.jl:209
  [6] Xranklin.LocalContext(glob::Xranklin.GlobalContext{Xranklin.LocalContext}, vars::Dict{Symbol, Any}, defs::Dict{String, Xranklin.LxDef}, headings::OrderedCollections.LittleDict{String, Tuple{Int64, Int64, String}, Vector{String}, Vector{Tuple{Int64, Int64, String}}}, rpath::String, alias::Dict{Symbol, Symbol})
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\context.jl:224
  [7] #LocalContext#16
    @ C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\context.jl:235 [inlined]
  [8] DefaultLocalContext(gc::Xranklin.GlobalContext{Xranklin.LocalContext}; rpath::String)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\default_context.jl:202
  [9] allocate_children_contexts(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, watched::Dict{Pair{String, String}, Float64})
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\full_pass.jl:253
 [10] full_pass_markdown(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, watched::Dict{Pair{String, String}, Float64}; skip_files::Vector{Pair{String, String}}, allow_skip::Bool, final::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\full_pass.jl:330
 [11] full_pass(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, watched_files::Dict{Symbol, Dict{Pair{String, String}, Float64}}; skip_files::Vector{Pair{String, String}}, initial_pass::Bool, layout_changed::Bool, config_changed::Bool, utils_changed::Bool, final::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\full_pass.jl:169
 [12] serve(d::String; dir::String, folder::String, clear::Bool, final::Bool, single::Bool, eval::Bool, nocode::Bool, threads::Bool, use_threads::Bool, prepath::String, prefix::String, base_url_prefix::String, debug::Bool, cleanup::Bool, skip::Vector{String}, port::Int64, host::String, launch::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\serve.jl:152
 [13] top-level scope
    @ REPL[10]:1
in expression starting at string:4
tlienart commented 1 year ago

alright bear with me, could you:

  1. remove any .toml file you have in the folder
  2. in a REPL activate the folder, and do add https://github.com/tlienart/Xranklin.jl

then

using Xranklin
serve(clear=true, debug=true)

your first few attempts likely generated a cache which is corrupt and so it's failing to load it, clear=true will remove that. There may still be errors of course but at least we'll get a clearer idea of what's going on

PS: I hope you didn't just copy paste your entire folder that you were using with Franklin and just tried with Xranklin? it should mostly work yes, but it'll be easier to fix small wrinkles if you start with one or two pages at first, clear out the repetitive errors, don't pollute the whole thing with executing foreign code yet, and once that's working add the content gradually

joa-quim commented 1 year ago

PS: I hope you didn't just copy paste your entire folder that you were using with Franklin and just tried with Xranklin? it should mostly work yes, but it'll be easier to fix small wrinkles if you start with one or two pages at first, clear out the repetitive errors, don't pollute the whole thing with executing foreign code yet, and once that's working add the content gradually

Off course I did 😄 But took the care of replacing all references to Franklin by Xranklin.

Unfortunately nope

┌ Debug: � ... try_form_lxdef > \newcommand
└ @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\misc_utils.jl:105
[ Info: ... [config.md] ✔ (δt = 16ms)

[ Info: � starting the full pass

ERROR: LoadError: syntax: invalid escape sequence
Stacktrace:
  [1] top-level scope
    @ string:4
  [2] eval
    @ .\boot.jl:373 [inlined]
  [3] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:1196
  [4] include_string (repeats 2 times)
    @ .\loading.jl:1206 [inlined]
  [5] modules_setup(c::Xranklin.LocalContext)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\code\modules.jl:209
  [6] Xranklin.LocalContext(glob::Xranklin.GlobalContext{Xranklin.LocalContext}, vars::Dict{Symbol, Any}, defs::Dict{String, Xranklin.LxDef}, headings::OrderedCollections.LittleDict{String, Tuple{Int64, Int64, String}, Vector{String}, Vector{Tuple{Int64, Int64, String}}}, rpath::String, alias::Dict{Symbol, Symbol})
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\context.jl:224
  [7] #LocalContext#16
    @ C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\context.jl:235 [inlined]
  [8] DefaultLocalContext(gc::Xranklin.GlobalContext{Xranklin.LocalContext}; rpath::String)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\context\default_context.jl:202
  [9] allocate_children_contexts(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, watched::Dict{Pair{String, String}, Float64})
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\full_pass.jl:253
 [10] full_pass_markdown(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, watched::Dict{Pair{String, String}, Float64}; skip_files::Vector{Pair{String, String}}, allow_skip::Bool, final::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\full_pass.jl:330
 [11] full_pass(gc::Xranklin.GlobalContext{Xranklin.LocalContext}, watched_files::Dict{Symbol, Dict{Pair{String, String}, Float64}}; skip_files::Vector{Pair{String, String}}, initial_pass::Bool, layout_changed::Bool, config_changed::Bool, utils_changed::Bool, final::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\full_pass.jl:169
 [12] serve(d::String; dir::String, folder::String, clear::Bool, final::Bool, single::Bool, eval::Bool, nocode::Bool, threads::Bool, use_threads::Bool, prepath::String, prefix::String, base_url_prefix::String, debug::Bool, cleanup::Bool, skip::Vector{String}, port::Int64, host::String, launch::Bool)
    @ Xranklin C:\Users\joaqu\.julia\packages\Xranklin\aymG1\src\build\serve.jl:152
 [13] top-level scope
    @ REPL[7]:1
in expression starting at string:4
tlienart commented 1 year ago

Could you paste the content of config.md here? or better yet, could you put some minimal stuff in a draft repo that we could both work on? (i.e. with maybe only the landing page and one content page). It looks like one of your \newcommand has something weird in it. Though that's not what's crashing Xranklin but I'd need to have the minimal repo to figure that one out.

joa-quim commented 1 year ago

First is easier https://github.com/GenericMappingTools/GMTjl_doc/blob/master/config.md

Second demands more time. Note, you still have rights on https://github.com/joa-quim/GMTjl_doc That is not the copy I'm working on but should be very close. Except the Franknlin -> Xranklin replacement.