From d49b3941bdf9ab7201128f48e2afb31e55369f89 Mon Sep 17 00:00:00 2001 From: webofceco Date: Fri, 24 May 2024 01:09:42 -0400 Subject: [PATCH] updated readme and docstrings --- CITATION.bib | 12 ++++--- Project.toml | 2 +- README.md | 26 +------------- src/docstrings.jl | 91 ++++++++++++++++++++++++++++++----------------- src/viewing.jl | 8 +++-- src/writing.jl | 6 ++-- 6 files changed, 78 insertions(+), 67 deletions(-) diff --git a/CITATION.bib b/CITATION.bib index 59d829f..d6cac18 100644 --- a/CITATION.bib +++ b/CITATION.bib @@ -1,6 +1,10 @@ @software{HTMLTables.jl, - author = {Ceco E. Maples}, - title = {HTMLTables.jl}, - howpublished = {\url{https://github.com/cecoeco/HTMLTables.jl}}, - year = {2024} + author = {Maples, Ceco Elijah}, + title = {HTMLTables.jl: Julia Package for Reading, Writing, and Viewing HTML Tables}, + month = may, + year = 2024, + publisher = {Zenodo}, + version = {v0.3.5}, + doi = {10.5281/zenodo.11253770}, + url = {https://doi.org/10.5281/zenodo.11253770} } \ No newline at end of file diff --git a/Project.toml b/Project.toml index 1578a58..bea6914 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "HTMLTables" uuid = "b1afcece-b80e-4563-b90e-36b4cc56d3fa" authors = ["Ceco E. Maples "] -version = "0.3.4" +version = "0.3.5" [deps] Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f" diff --git a/README.md b/README.md index 5ea90e8..b0f5708 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,11 @@ CI test Style: Blue Documentation Stable +DOI Contributor Covenant - # HTMLTables - Julia package for reading, writing, and viewing HTML tables. Reading HTML tables: @@ -26,29 +25,6 @@ Viewing HTML tables: - `HTMLTables.display` displays a julia table as an HTML table in julia. - `HTMLTables.open` opens a julia table as an HTML table in the browser. -## example -```julia -using DataFrames, HTMLTables - -df = DataFrame( - "a" => [001, 002, 003, 004, 005, 006, 007, 008, 009, 010], - "b" => [011, 012, 013, 014, 015, 016, 017, 018, 019, 020], - "c" => [021, 022, 023, 024, 025, 026, 027, 028, 029, 030], - "d" => [031, 032, 033, 034, 035, 036, 037, 038, 039, 040], - "e" => [041, 042, 043, 044, 045, 046, 047, 048, 049, 050], - "f" => [051, 052, 053, 054, 055, 056, 057, 058, 059, 060], - "g" => [061, 062, 063, 064, 065, 066, 067, 068, 069, 070], - "h" => [071, 072, 073, 074, 075, 076, 077, 078, 079, 080], - "i" => [081, 082, 083, 084, 085, 086, 087, 088, 089, 090], - "j" => [091, 092, 093, 094, 095, 096, 097, 098, 099, 100] -) - -HTMLTables.png(df, filename="example", caption="example table: 10x10", colorscale="Blues") - -``` -the resulting table: -![example table](assets/example.png) - ## License Copyright © 2024 Ceco Elijah Maples diff --git a/src/docstrings.jl b/src/docstrings.jl index 2d1a36e..6f79c1b 100644 --- a/src/docstrings.jl +++ b/src/docstrings.jl @@ -1,4 +1,5 @@ -const get_docstrings::String = """ +const get_docstrings::String = +""" HTMLTables.get(source::String; id::String="", classes::Union{Vector{String},String}="", index::Int=1) Returns an HTML table a source as a string. @@ -12,8 +13,9 @@ Returns an HTML table a source as a string. """ -const read_docstrings::String = """ - HTMLTables.read(source::String; id::String="", classes::Union{Vector{String},String}="") +const read_docstrings::String = +""" + HTMLTables.read(source::String, sink::Function; id::String="", classes::Union{Vector{String},String}="") Reads a HTML table into a sink function such as `DataFrame`. @@ -55,7 +57,23 @@ XLSX.writetable("table.xlsx", "Sheet 1" => df) ``` """ -const table_docstrings::String = """ +const TABLE_KEYWORDS_ARGUMENTS::String = +""" +- `tbl`: The table to write. +- `filename`: The filename of the HTML table. +- `save_location`: The location to save the HTML table. +- `header`: Whether to include the table header. +- `footer`: Whether to include the table footer. +- `id`: The id of the HTML table. +- `classes`: The classes of the HTML table. +- `css`: Whether to include the CSS styles. +- `theme`: The theme of the HTML table. +- `colorscale`: The colorscale of the HTML table. +- `tooltips`: Whether to include tooltips. +""" + +const table_docstrings::String = +""" HTMLTables.table( tbl; header::Bool=true, @@ -72,15 +90,7 @@ Returns a julia table as an HTML table. ## Arguments -- `tbl`: The table to write. -- `header`: Whether to include the table header. -- `footer`: Whether to include the table footer. -- `id`: The id of the HTML table. -- `classes`: The classes of the HTML table. -- `css`: Whether to include the CSS styles. -- `theme`: The theme of the HTML table. -- `colorscale`: The colorscale of the HTML table. -- `tooltips`: Whether to include tooltips. +$TABLE_KEYWORDS_ARGUMENTS ## Returns @@ -99,7 +109,8 @@ println(html) ``` """ -const write_docstrings::String = """ +const write_docstrings::String = +""" HTMLTables.write( tbl; filename::String="table", @@ -111,56 +122,72 @@ Writes a julia table as an HTML table to an HTML file. ## Arguments -- `tbl`: The table to write. -- `filename`: The filename of the HTML table. -- `save_location`: The location to save the HTML table. -- `header`: Whether to include the table header. -- `footer`: Whether to include the table footer. -- `id`: The id of the HTML table. -- `classes`: The classes of the HTML table. -- `css`: Whether to include the CSS styles. -- `theme`: The theme of the HTML table. -- `colorscale`: The colorscale of the HTML table. -- `tooltips`: Whether to include tooltips. +$TABLE_KEYWORDS_ARGUMENTS ## Returns - `path`: The path to the HTML file. """ -const jpg_docstrings::String = """ +const jpg_docstrings::String = +""" HTMLTables.jpg(tbl; kwargs...) Writes an HTML table as a JPG image. + +## Arguments + +$TABLE_KEYWORDS_ARGUMENTS """ -const pdf_docstrings::String = """ +const pdf_docstrings::String = +""" HTMLTables.pdf(tbl; kwargs...) Writes an HTML table as a PDF document. + +## Arguments + +$TABLE_KEYWORDS_ARGUMENTS """ -const png_docstrings::String = """ +const png_docstrings::String = +""" HTMLTables.png(tbl; kwargs...) Writes an HTML table as a PNG image. + +## Arguments + +$TABLE_KEYWORDS_ARGUMENTS """ -const open_docstrings::String = """ +const open_docstrings::String = +""" HTMLTables.open(tbl; kwargs...) Opens a julia table as an HTML table in the browser. + +## Arguments + +$TABLE_KEYWORDS_ARGUMENTS + + +## Returns + +- `path`: The path to the HTML file. + """ -const display_docstrings::String = """ +const display_docstrings::String = +""" HTMLTables.display(tbl; kwargs...) Displays a julia table as an HTML table in julia. ## Arguments -- `tbl`: The table to display. -- `kwargs`: Keyword arguments to pass to the `HTMLTables.table` function. +$TABLE_KEYWORDS_ARGUMENTS ## Examples diff --git a/src/viewing.jl b/src/viewing.jl index 4232c4e..cf5cc35 100644 --- a/src/viewing.jl +++ b/src/viewing.jl @@ -1,7 +1,7 @@ """ $open_docstrings """ -function open(tbl; kwargs...) +function open(tbl; kwargs...)::String path::String = write(tbl; kwargs...) if Base.Sys.iswindows() @@ -11,6 +11,10 @@ function open(tbl; kwargs...) elseif Base.Sys.isapple() Base.run(`open $path`) end + + Base.println("Opening $path in your default browser...") + + return path end """ @@ -19,5 +23,5 @@ $display_docstrings function display(tbl; kwargs...) html_table::String = table(tbl; kwargs...) - Base.Multimedia.display("juliavscode/html", html_table) + return Base.Multimedia.display("juliavscode/html", html_table) end \ No newline at end of file diff --git a/src/writing.jl b/src/writing.jl index c70fa63..3f72f57 100644 --- a/src/writing.jl +++ b/src/writing.jl @@ -362,14 +362,14 @@ end """ $jpg_docstrings """ -jpg(tbl; kwargs...) = converttable(tbl, "jpg"; kwargs...) +jpg(tbl; kwargs...)::String = converttable(tbl, "jpg"; kwargs...) """ $pdf_docstrings """ -pdf(tbl; kwargs...) = converttable(tbl, "pdf"; kwargs...) +pdf(tbl; kwargs...)::String = converttable(tbl, "pdf"; kwargs...) """ $png_docstrings """ -png(tbl; kwargs...) = converttable(tbl, "png"; kwargs...) +png(tbl; kwargs...)::String = converttable(tbl, "png"; kwargs...)