From 216d67cfdbac33456638aaa290d73b08314876ef Mon Sep 17 00:00:00 2001 From: jbrea Date: Thu, 24 Jun 2021 11:40:20 +0200 Subject: [PATCH] Show descriptions of data sets. --- src/dataset.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dataset.jl b/src/dataset.jl index 494fe00..cecd640 100644 --- a/src/dataset.jl +++ b/src/dataset.jl @@ -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