Skip to content

Commit

Permalink
Show descriptions of data sets. (#146)
Browse files Browse the repository at this point in the history
Co-authored-by: jbrea <[email protected]>
  • Loading branch information
asinghvi17 and jbrea authored Apr 2, 2024
1 parent 8835c68 commit 56d065c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,19 @@ function dataset(package_name::AbstractString, dataset_name::AbstractString)
end
error("Unable to locate dataset file $rdaname or $csvname")
end

struct RDatasetsDescription
content::String
end
function description(package_name::AbstractString, dataset_name::AbstractString)
RDatasetsDescription(read(joinpath(@__DIR__, "..", "doc",
package_name, "$dataset_name.html"), String))
end
function Base.show(io::IO, mime::MIME"text/plain", d::RDatasetsDescription)
nohtml = replace(d.content, Regex("<[^>]*>") => "")
s = replace(nohtml, Regex("\n\n+") => "\n\n")
show(io, mime, Docs.Text(s))
end
function Base.show(io::IO, mime::MIME"text/html", d::RDatasetsDescription)
show(io, mime, HTML(d.content))
end

0 comments on commit 56d065c

Please sign in to comment.