Skip to content

Commit

Permalink
Another improvement to HTML representations
Browse files Browse the repository at this point in the history
  • Loading branch information
cadojo committed Aug 20, 2023
1 parent ac603b7 commit 00afc91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CommonLicenses"
uuid = "31d8bc61-a8a5-4aaa-ae43-a3b73cb73fef"
authors = ["Joe Carpinelli <joseph.d.carpinelli@loopy.software>"]
version = "0.1.1"
authors = ["Joe Carpinelli <joey@loopy.codes>"]
version = "0.1.2"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
27 changes: 16 additions & 11 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,32 @@ A supertype for all licenses.
All `License` subtypes should have the following methods defined:
- `Licenses.name(license)::AbstractString`
- `Licenses.spdx(license)::AbstractString`
- `Licenses.text(license)::AbstractString`
- `CommonLicenses.name(license)::AbstractString`
- `CommonLicenses.spdx(license)::AbstractString`
- `CommonLicenses.text(license)::AbstractString`
The following methods may be optionally defined.
- `Licenses.conditions(license)::AbstractSet{<:AbstractString}`
- `Licenses.permissions(license)::AbstractSet{<:AbstractString}`
- `Licenses.limitations(license)::AbstractSet{<:AbstractString}`
- `Licenses.arguments(license)::NTuple{N,Pair{<:AbstractString,Symbol}} where {N}`
- `Licenses.defaults(license)::NTuple{N,Pair{Symbol,<:Any}} where {N}`
- `CommonLicenses.conditions(license)::AbstractSet{<:AbstractString}`
- `CommonLicenses.permissions(license)::AbstractSet{<:AbstractString}`
- `CommonLicenses.limitations(license)::AbstractSet{<:AbstractString}`
- `CommonLicenses.arguments(license)::NTuple{N,Pair{<:AbstractString,Symbol}} where {N}`
- `CommonLicenses.defaults(license)::NTuple{N,Pair{Symbol,<:Any}} where {N}`
"""
abstract type AbstractLicense end

Base.show(io::IO, ::MIME"text/plain", license::AbstractLicense) = println(io, text(license))

function Base.show(io::IO, ::MIME"text/html", license::AbstractLicense)
contract = replace(text(license), "\n" => "<br>")
header = name(license)
if !occursin("license", lowercase(header))
header = "$header License"
end

content = """
<details>
<summary>$(name(license))</summary>
<summary>$(header)</summary>
<code>
$(contract)
</code>
Expand Down Expand Up @@ -114,7 +119,7 @@ Specify default values for each license argument.
# Extended Help
See also, `Licenses.arguments`.
See also, `CommonLicenses.arguments`.
"""
function defaults end

Expand All @@ -123,7 +128,7 @@ Return all required arguments.
# Extended Help
See also, `Licenses.arguments`.
See also, `CommonLicenses.arguments`.
"""
function required(license::AbstractLicense)
return map(
Expand Down

4 comments on commit 00afc91

@cadojo
Copy link
Owner Author

@cadojo cadojo commented on 00afc91 Aug 20, 2023

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Error while trying to register: "Tag with name v0.1.2 already exists and points to a different commit"

@cadojo
Copy link
Owner Author

@cadojo cadojo commented on 00afc91 Aug 20, 2023

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/89974

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.2 -m "<description of version>" 00afc911d352c07a3a0a23a6226d892849b1c9ee
git push origin v0.1.2

Please sign in to comment.