Skip to content

Commit

Permalink
updated readme and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
cecoeco committed May 24, 2024
1 parent e6713bb commit d49b394
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 67 deletions.
12 changes: 8 additions & 4 deletions CITATION.bib
Original file line number Diff line number Diff line change
@@ -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}
}
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "HTMLTables"
uuid = "b1afcece-b80e-4563-b90e-36b4cc56d3fa"
authors = ["Ceco E. Maples <[email protected]>"]
version = "0.3.4"
version = "0.3.5"

[deps]
Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f"
Expand Down
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
<a href="https://github.com/cecoeco/HTMLTables.jl/actions/workflows/CI.yml"><img alt="CI test" src="https://github.com/cecoeco/HTMLTables.jl/actions/workflows/CI.yml/badge.svg"></a>
<a href="https://github.com/JuliaDiff/BlueStyle"><img alt="Style: Blue" src="https://img.shields.io/badge/code%20style-blue-4495d1.svg"></a>
<a href='https://cecoeco.github.io/HTMLTables.jl/stable/'><img src='https://img.shields.io/badge/docs-stable-blue.svg' alt='Documentation Stable' /></a>
<a href="https://zenodo.org/doi/10.5281/zenodo.11253769"><img src="https://zenodo.org/badge/779591300.svg" alt="DOI"></a>
<a href='https://www.contributor-covenant.org'><img src='https://img.shields.io/badge/Contributor%20Covenant-v2.1%20adopted-ff69b4.svg' alt='Contributor Covenant'></a>

</div>

# HTMLTables

Julia package for reading, writing, and viewing HTML tables.

Reading HTML tables:
Expand All @@ -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

Expand Down
91 changes: 59 additions & 32 deletions src/docstrings.jl
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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`.
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -99,7 +109,8 @@ println(html)
```
"""

const write_docstrings::String = """
const write_docstrings::String =
"""
HTMLTables.write(
tbl;
filename::String="table",
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/viewing.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
$open_docstrings
"""
function open(tbl; kwargs...)
function open(tbl; kwargs...)::String
path::String = write(tbl; kwargs...)

if Base.Sys.iswindows()
Expand All @@ -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

"""
Expand All @@ -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
6 changes: 3 additions & 3 deletions src/writing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)

0 comments on commit d49b394

Please sign in to comment.