Skip to content
12 changes: 8 additions & 4 deletions docs/display_parameters.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# I'm sure there are other libraries that can do this
function parameter_table(labels, values)
label_width = maximum((length("$label") for label in labels))
value_width = maximum((length("$value") for value in values))
# sanitize a value so it stays inside a single markdown table row
clean(v) = let s = "$v"
s = replace(s, r"\r?\n\s*" => "<br>") # newlines -> HTML break (drop indent)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe this still needs to be \n but the "|" escaping is what atually needed fixing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I do think that removing \n is needed. As you can see from the screen shot,
image
The Is = ....that is after an \n is in the second line.

Perhaps we just need to change <br> to something else that the documentation can recognize. Sorry, I should have tested this on my side with the documentation. Unfortunately, I still have some difficulties with generating the documentation on my side, and won’t have time to work on this for a couple of days. If you know what this error is, it would be quite helpful.

ERROR: LoadError: `makedocs` encountered an error [:example_block] -- terminating build before rendering.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:44
  [2] runner(::Type{Documenter.Builder.RenderDocument}, doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/AXNMp/src/builder_pipeline.jl:259
  [3] dispatch(::Type{Documenter.Builder.DocumentPipeline}, x::Documenter.Document)
    @ Documenter.Selectors ~/.julia/packages/Documenter/AXNMp/src/utilities/Selectors.jl:170
  [4] #95
    @ ~/.julia/packages/Documenter/AXNMp/src/makedocs.jl:283 [inlined]
  [5] withenv(::Documenter.var"#95#96"{Documenter.Document}, ::Pair{String, Nothing}, ::Vararg{Pair{String, Nothing}})
    @ Base ./env.jl:265
  [6] #93
    @ ~/.julia/packages/Documenter/AXNMp/src/makedocs.jl:282 [inlined]
  [7] cd(f::Documenter.var"#93#94"{Documenter.Document}, dir::String)
    @ Base.Filesystem ./file.jl:112
  [8] makedocs(; debug::Bool, format::Documenter.HTMLWriter.HTML, kwargs::@Kwargs{sitename::String, authors::String, pages::Vector{Pair{String, Any}}, modules::Vector{Module}, plugins::Vector{CitationBibliography}, doctest::Bool, clean::Bool, checkdocs::Symbol})
    @ Documenter ~/.julia/packages/Documenter/AXNMp/src/makedocs.jl:281
  [9] top-level scope
    @ ~/Documents/pkg_dvlp/OceanBioME.jl/docs/make.jl:137
 [10] include(mod::Module, _path::String)
    @ Base ./Base.jl:306
 [11] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:317
 [12] _start()
    @ Base ./client.jl:550
in expression starting at /Users/kuailv/Documents/pkg_dvlp/OceanBioME.jl/docs/make.jl:137

If not, I will circle back to this in a couple of days.

s = replace(s, "|" => "\\|") # escape pipes so they don't split cells
s
end

output = "|Name | Value |\n|---|---|\n"

for (idx, label) in enumerate(labels)
output *= "|$label|$(values[idx])|\n"
output *= "|$label|$(clean(values[idx]))|\n"
end

return output
Expand Down Expand Up @@ -48,4 +52,4 @@ function create_parameter_file!(model, name, path)
open(path,"w+") do io
println(io, output)
end
end
end