From 03082dac9f4b5f70b1b3655d6c414e8e45908e9a Mon Sep 17 00:00:00 2001 From: Azzaare Date: Sat, 2 Nov 2024 13:41:11 +0900 Subject: [PATCH] Update for Julia new lts. Update for Bibliography v0.3 --- .JuliaFormatter.toml | 1 + .github/dependabot.yml | 7 +++ .github/workflows/CompatHelper.yml | 37 ++++++++++++--- .github/workflows/SpellCheck.yml | 15 +++++++ .github/workflows/TagBot.yml | 16 +++++++ .github/workflows/ci.yml | 72 ++++++++++++++++++++++++------ .github/workflows/register.yml | 16 +++++++ Project.toml | 16 +++++-- _typos.toml | 3 ++ docs/make.jl | 31 ++++++------- example/content.jl | 72 +++++++++++++++--------------- example/run.jl | 2 +- example/token.jl | 2 +- ext/SWPGtkExt.jl | 3 +- src/StaticWebPages.jl | 8 ++-- src/constant.jl | 27 ++++++----- src/inline.jl | 2 +- src/io.jl | 20 ++++----- src/items.jl | 15 +++---- src/items/block.jl | 6 +-- src/items/card.jl | 2 +- src/items/carousel.jl | 1 + src/items/git.jl | 10 ++--- src/items/publications.jl | 4 +- src/items/timeline.jl | 2 +- src/page.jl | 16 +++---- src/skeleton.jl | 8 ++-- test/Aqua.jl | 24 ++++++++++ test/ExplicitImports.jl | 4 ++ test/JET.jl | 3 ++ test/Project.toml | 2 - test/TestItemRunner.jl | 3 ++ test/internal.jl | 34 ++++++++++++++ test/run.jl | 2 +- test/runtests.jl | 46 +++++-------------- 35 files changed, 358 insertions(+), 174 deletions(-) create mode 100644 .JuliaFormatter.toml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/SpellCheck.yml create mode 100644 .github/workflows/register.yml create mode 100644 _typos.toml create mode 100644 test/Aqua.jl create mode 100644 test/ExplicitImports.jl create mode 100644 test/JET.jl delete mode 100644 test/Project.toml create mode 100644 test/TestItemRunner.jl create mode 100644 test/internal.jl diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..453925c --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "sciml" \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..700707c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index cba9134..5577817 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -1,16 +1,43 @@ -name: CompatHelper on: schedule: - cron: 0 0 * * * workflow_dispatch: +permissions: + contents: write + pull-requests: write jobs: CompatHelper: runs-on: ubuntu-latest steps: - - name: Pkg.add("CompatHelper") - run: julia -e 'using Pkg; Pkg.add("CompatHelper")' - - name: CompatHelper.main() + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v1 + with: + version: "1" + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main() + shell: julia --color=yes {0} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} - run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..9146006 --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -0,0 +1,15 @@ +name: Spell Check + +on: [pull_request] + +jobs: + typos-check: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Check spelling + uses: crate-ci/typos@v1.18.0 + with: + config: ./_typos.toml diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index f49313b..0cd3114 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -4,6 +4,22 @@ on: types: - created workflow_dispatch: + inputs: + lookback: + default: "3" +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read jobs: TagBot: if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc9d939..7315e33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,48 @@ name: CI on: - - push - - pull_request + pull_request: + branches: + - master + - dev + paths-ignore: + - "docs/**" + push: + branches: + - master + paths-ignore: + - "docs/**" jobs: + formatter: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + julia-arch: [x86] + os: [ubuntu-latest] + steps: + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.julia-version }} + + - uses: actions/checkout@v4 + - name: Install JuliaFormatter and format + # This will use the latest version by default but you can set the version like so: + # + # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.50"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Format check + run: | + julia -e ' + out = Cmd(`git diff`) |> read |> String + if out == "" + exit(0) + else + @error "Some files have not been formatted !!!" + write(stdout, out) + exit(1) + end' test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} @@ -10,26 +50,32 @@ jobs: fail-fast: false matrix: version: - - "nightly" + - "lts" + - "1" + - "pre" os: - ubuntu-latest - - macOS-latest - - windows-latest arch: - x64 - x86 - exclude: + include: + # test macOS and Windows with latest Julia only - os: macOS-latest - arch: x86 + arch: x64 + version: 1 + - os: windows-latest + arch: x64 + version: 1 - os: windows-latest arch: x86 + version: 1 steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: @@ -42,15 +88,15 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4 with: file: lcov.info docs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: "1" - run: | diff --git a/.github/workflows/register.yml b/.github/workflows/register.yml new file mode 100644 index 0000000..5b7cd3b --- /dev/null +++ b/.github/workflows/register.yml @@ -0,0 +1,16 @@ +name: Register Package +on: + workflow_dispatch: + inputs: + version: + description: Version to register or component to bump + required: true +jobs: + register: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: julia-actions/RegisterAction@latest + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Project.toml b/Project.toml index df9e75a..e712b97 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ authors = ["azzaare "] name = "StaticWebPages" uuid = "5bf9d097-888b-4aa7-96b5-1bfe21b2dbad" -version = "0.2.22" +version = "0.2.23" [deps] Bibliography = "f1be7e48-bf82-45af-a471-ae754a193061" @@ -16,9 +16,19 @@ Gtk4 = "9db2cae5-386f-4011-9d63-a5602296539b" SWPGtkExtension = ["Gtk4"] [compat] -Bibliography = "0.2" +Bibliography = "0.3" DataStructures = "0.18" FTPClient = "1" GitHub = "5" Gtk4 = "0.3" -julia = "1.9" +julia = "1.10" + +[extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" + +[targets] +test = ["Aqua", "ExplicitImports", "JET", "Test", "TestItemRunner"] diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..1f4ec6c --- /dev/null +++ b/_typos.toml @@ -0,0 +1,3 @@ +[default.extend-words] +# Don't correct the surname "Teh" +annote = "annote" \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index 078d23e..64fee5d 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -4,30 +4,31 @@ using Documenter @info "Makeing documentation..." makedocs(; - modules=[StaticWebPages, Bibliography], - authors="Jean-François Baffier", - repo="https://github.com/Humans-of-Julia/StaticWebPages.jl/blob/{commit}{path}#L{line}", - sitename="StaticWebPages.jl", - format=Documenter.HTML(; - prettyurls=get(ENV, "CI", "false") == "true", - canonical="https://Humans-of-Julia.github.io/StaticWebPages.jl", - assets = ["assets/favicon.ico"; "assets/github_buttons.js"; "assets/custom.css"], + modules = [StaticWebPages, Bibliography], + authors = "Jean-François Baffier", + repo = "https://github.com/Humans-of-Julia/StaticWebPages.jl/blob/{commit}{path}#L{line}", + sitename = "StaticWebPages.jl", + format = Documenter.HTML(; + prettyurls = get(ENV, "CI", "false") == "true", + canonical = "https://Humans-of-Julia.github.io/StaticWebPages.jl", + assets = ["assets/favicon.ico"; "assets/github_buttons.js"; "assets/custom.css"] ), - pages=[ + pages = [ "Home" => "index.md", "Components" => [ "Theming" => "themes.md", "Items" => "items.md", - "Pages" => "pages.md", + "Pages" => "pages.md" ], "Dependencies" => [ - "Bibliography.jl" => "bibliography.md", + "Bibliography.jl" => "bibliography.md" ], "Library" => [ "public.md", - "internal.md", - ], - ], + "internal.md" + ] + ] ) -deploydocs(; repo = "github.com/Humans-of-Julia/StaticWebPages.jl.git", devbranch = "master") +deploydocs(; + repo = "github.com/Humans-of-Julia/StaticWebPages.jl.git", devbranch = "master") diff --git a/example/content.jl b/example/content.jl index 0fdf8eb..18529a2 100644 --- a/example/content.jl +++ b/example/content.jl @@ -147,25 +147,25 @@ biography = Block( ) page( - title="index", - sections=[ + title = "index", + sections = [ Section( - title="Biography", - items=biography + title = "Biography", + items = biography ), Double( Section( - title="Positions", - items=work_cards + title = "Positions", + items = work_cards ), Section( - title="Education", - items=education_cards + title = "Education", + items = education_cards ) ), Section( - title="Grants", - items=grants + title = "Grants", + items = grants ) ] ) @@ -175,13 +175,13 @@ page( # option 1: background for the page is set to start with white to emphasize the items ###################################### page( - title="publications", - background=bg_white, - sections=[ + title = "publications", + background = bg_white, + sections = [ Section( - title="Publications", - items=Publications("publications.bib") - ) + title = "Publications", + items = Publications("publications.bib") + ) ] ) @@ -259,28 +259,28 @@ explainable = Block( ) page( - title="research", - sections=[ + title = "research", + sections = [ Section( - title="Research topics", - items=topics + title = "Research topics", + items = topics ), Section( - title="Network Interdiction", - items=interdiction + title = "Network Interdiction", + items = interdiction ), Section( - title="Compressed Data Sructures", - items=structure + title = "Compressed Data Sructures", + items = structure ), Section( - title="Modern Academics", - items=modernac + title = "Modern Academics", + items = modernac ), Section( - title="Explainable Artificial Intelligence", - items=explainable - ),] + title = "Explainable Artificial Intelligence", + items = explainable + )] ) ###################################### @@ -301,14 +301,14 @@ github = GitRepo( ) page( - title="software", - background=bg_white, - sections=[ + title = "software", + background = bg_white, + sections = [ Section( - title="Software", - hide=true, - items=github, - ) + title = "Software", + hide = true, + items = github + ) ] ) diff --git a/example/run.jl b/example/run.jl index 352ee8f..75915a4 100644 --- a/example/run.jl +++ b/example/run.jl @@ -18,7 +18,7 @@ local_info["server"] = "server_address" # `rm_dir = true` will clean up the site folder before generating it again. Default to false. # `opt_in = true` will a link to this generator website in the side menu. Default to false. -StaticWebPages.export_site(d=local_info, rm_dir = true, opt_in = true) +StaticWebPages.export_site(d = local_info, rm_dir = true, opt_in = true) ## upload website (comment/delete if not needed) # unfortunately does not work yet on windows system, please sync manually for the moment diff --git a/example/token.jl b/example/token.jl index a754c12..92ee6c1 100644 --- a/example/token.jl +++ b/example/token.jl @@ -2,4 +2,4 @@ # YOUR TOKENS SHOULD NEVER BE SHARED! IF YOU USE GIT, DON'T FORGET TO ADD `token.jl` TO YOUR `.gitignore` FILE! # YOU CAN ALSO STORE `token.jl` OUTSIDE OF THE STATICWEBPAGES FOLDER! -github_pat = "YOUR_PERSONAL_ACCESS_TOKEN" +github_pat = "YOUR_PERSONAL_ACCESS_TOKEN" diff --git a/ext/SWPGtkExt.jl b/ext/SWPGtkExt.jl index 20e2bbf..f0c39c3 100644 --- a/ext/SWPGtkExt.jl +++ b/ext/SWPGtkExt.jl @@ -31,7 +31,8 @@ end set_subtitle!(widget, str) = set_gtk_property!(widget, :subtitle, str) function choose_project_folder(win) - dir = open_dialog("Select content.jl folder", win, action=GtkFileChooserAction.SELECT_FOLDER) + dir = open_dialog( + "Select content.jl folder", win, action = GtkFileChooserAction.SELECT_FOLDER) if isdir(dir) set_subtitle!(header, "$(pwd())") end diff --git a/src/StaticWebPages.jl b/src/StaticWebPages.jl index 8240713..568e85d 100644 --- a/src/StaticWebPages.jl +++ b/src/StaticWebPages.jl @@ -1,8 +1,8 @@ module StaticWebPages -using DataStructures -using FTPClient -using GitHub +import DataStructures: OrderedDict +import FTPClient: FTP +import GitHub: Repo import Base.show @@ -23,8 +23,6 @@ export GitRepo export TimeLine export TimeLineColor -export ui - function load_example() include(joinpath(@__DIR__, "..", "example", "content.jl")) end diff --git a/src/constant.jl b/src/constant.jl index 43aeb07..f98e2a7 100644 --- a/src/constant.jl +++ b/src/constant.jl @@ -95,7 +95,7 @@ end A dictionary to translate the enumeration in ColorLabel to actual HTML/CSS labels. An optional `black-text` color for text is given (it defaults to white-text). """ -const color_to_label = Dict{ColorLabel,String}([ +const color_to_label = Dict{ColorLabel, String}([ red => "label-red", green => "label-green", yellow => "label-yellow black-text", @@ -117,10 +117,9 @@ const color_to_label = Dict{ColorLabel,String}([ navy => "label-navy", grey => "label-grey", white => "label-white black-text", - black => "label-black", + black => "label-black" ]) - """ CardColor @@ -150,7 +149,7 @@ end A dictionary to translate the enumeration in CardColor to actual HTML/CSS attributes. A card can be composed of either one or two colors. """ -const color_to_card = Dict{CardColor,Tuple{String,String}}([ +const color_to_card = Dict{CardColor, Tuple{String, String}}([ card_blue => ("blue-first", "blue-second"), card_green => ("green-first", "green-second"), card_red => ("red-first", "red-second"), @@ -158,7 +157,7 @@ const color_to_card = Dict{CardColor,Tuple{String,String}}([ card_julia_blue => ("julia-blue", "julia-blue"), card_julia_green => ("julia-green", "julia-green"), card_julia_purple => ("julia-purple", "julia-purple"), - card_julia_red => ("julia-red", "julia-red"), + card_julia_red => ("julia-red", "julia-red") ]) """ @@ -192,7 +191,7 @@ end A dictionary to translate the enumeration in `TimeLineColor` to actual HTML/CSS attributes. """ -const color_to_timeline = Dict{TimeLineColor,Tuple{String,String}}([ +const color_to_timeline = Dict{TimeLineColor, Tuple{String, String}}([ tl_blue => ("tl-blue-bg", "tl-blue-border"), tl_green => ("tl-green-bg", "tl-green-border"), tl_red => ("tl-red-bg", "tl-red-border"), @@ -200,7 +199,7 @@ const color_to_timeline = Dict{TimeLineColor,Tuple{String,String}}([ tl_julia_blue => ("julia-blue", "julia-blue-border"), tl_julia_green => ("julia-green", "julia-green-border"), tl_julia_purple => ("julia-purple", "julia-purple-border"), - tl_julia_red => ("julia-red", "julia-red-border"), + tl_julia_red => ("julia-red", "julia-red-border") ]) """ @@ -208,14 +207,14 @@ const color_to_timeline = Dict{TimeLineColor,Tuple{String,String}}([ A dictionary that tracks the HTML/CSS attributes for icons from font-awesome. """ -const academicons = Dict{String,String}([ +const academicons = Dict{String, String}([ "researchgate" => "ai ai-researchgate-square", "googlescholar" => "ai ai-google-scholar-square", "orcid" => "ai ai-orcid-square", "dblp" => "ai ai-dblp-square", "github" => "fa fa-github-square", "linkedin" => "fab fa-linkedin", - "twitter" => "fa fa-twitter-square", + "twitter" => "fa fa-twitter-square" ]) """ @@ -223,7 +222,7 @@ const academicons = Dict{String,String}([ A dictionary, with default values, used to customize personal information. """ -const info = Dict{String,String}([ +const info = Dict{String, String}([ "title" => "title", "avatar" => "pic.jpg", "name" => "name", "lang" => "en" ]) @@ -232,14 +231,14 @@ const info = Dict{String,String}([ An ordered dictionary to store the different web pages. """ -const content = OrderedDict{String,Any}() +const content = OrderedDict{String, Any}() """ local_info A dictionary that stores local information required to build and export the website. """ -const local_info = Dict{String,String}() +const local_info = Dict{String, String}() """ user_to_name @@ -248,11 +247,11 @@ A dictionary to translate user id (such as GitHub id) to real name. Normal use i When a list of id is too long, priority is given to the id with an associated name. """ -const user_to_name = Dict{String,String}() +const user_to_name = Dict{String, String}() """ publication_labels An ordered dictionary to store the attributions of labels to keywords in a `Publications`. """ -const publication_labels = OrderedDict{String,ColorLabel}() +const publication_labels = OrderedDict{String, ColorLabel}() diff --git a/src/inline.jl b/src/inline.jl index 50ff6c4..29336b1 100644 --- a/src/inline.jl +++ b/src/inline.jl @@ -49,6 +49,6 @@ function email(e::Email) end end -function email(address::String; content::String="contact", obfuscated::Bool=true) +function email(address::String; content::String = "contact", obfuscated::Bool = true) return email(Email(address, content, obfuscated)) end diff --git a/src/io.jl b/src/io.jl index 7fcff94..28c62e0 100644 --- a/src/io.jl +++ b/src/io.jl @@ -7,7 +7,7 @@ If `rm_dir` is `true`, the `site` folder will be deleted before the website is g Users can choose to support `StaticWebPages.jl` by setting `opt_in` to `true`. This will add a small banner in the side navigation menu stating "This website was generated using StaticWebPages.jl" and links to the GitHub repository. """ function export_site(; - d::Dict{String,String}=local_info, rm_dir::Bool=false, opt_in::Bool=false + d::Dict{String, String} = local_info, rm_dir::Bool = false, opt_in::Bool = false ) # Loading github pat ; optional if no file is provided ; github_pat variable existence is check in git.jl @@ -17,26 +17,26 @@ function export_site(; @info "\nStaticWebPages.jl's generator is starting ...\n" if rm_dir - rm(d["site"]; recursive=true, force=true) + rm(d["site"]; recursive = true, force = true) mkpath(d["site"]) end for p in [ joinpath(d["site"], "files"), joinpath(d["site"], "img"), joinpath(d["site"], "js"), - joinpath(d["site"], "css"), + joinpath(d["site"], "css") ] !isdir(p) && mkpath(p) end - assets = joinpath(dirname(dirname(pathof(StaticWebPages))), "assets") + assets = joinpath(dirname(dirname(something(pathof(StaticWebPages), ""))), "assets") for p in ["js", "css"] - cp(joinpath(assets, p), joinpath(d["site"], p); force=true) + cp(joinpath(assets, p), joinpath(d["site"], p); force = true) end for p in ["files", "img"] str = joinpath(d["content"], p) - isdir(str) && cp(str, joinpath(d["site"], p); force=true) + isdir(str) && cp(str, joinpath(d["site"], p); force = true) end include(joinpath(d["content"], "content.jl")) @@ -57,7 +57,7 @@ end Will upload the generated website according to the info in `d`. """ -function upload_site(d::Dict{String,String}=local_info) +function upload_site(d::Dict{String, String} = local_info) protocol = d["protocol"] user = d["user"] password = d["password"] @@ -70,16 +70,16 @@ function upload_site(d::Dict{String,String}=local_info) for (root, dirs, files) in walkdir(".") for dir in dirs try - mkdir(ftp, replace(joinpath(root, dir), "\\" => "/")) + FTP.mkdir(ftp, replace(joinpath(root, dir), "\\" => "/")) catch e end end for file in files str = replace(joinpath(root, file), "\\" => "/") println("root:$root, joinpath:$str, file:$file") - upload(ftp, str, str) + FTP.upload(ftp, str, str) end end cd(temppath) - return close(ftp) + return FTP.close(ftp) end diff --git a/src/items.jl b/src/items.jl index 8f0bffa..bc4e524 100644 --- a/src/items.jl +++ b/src/items.jl @@ -18,8 +18,7 @@ include("items/publications.jl") include("items/block.jl") include("items/timeline.jl") -Item = Union{Deck,GitRepo,Publications,Block,TimeLine} - +Item = Union{Deck, GitRepo, Publications, Block, TimeLine} """ to_html(args...) @@ -38,7 +37,7 @@ struct Nest Nest(args...) = new([item for item in args]) end -SectionItems = Union{Item,Nest} +SectionItems = Union{Item, Nest} function to_html(nest::Nest) str = "" @@ -75,11 +74,11 @@ Create a new single column section. ) """ function Section(; - bgcolor::BackgroundColor=bg_none, - hide::Bool=false, - items::SectionItems=Nest(), - title::String="", - title_size=0 + bgcolor::BackgroundColor = bg_none, + hide::Bool = false, + items::SectionItems = Nest(), + title::String = "", + title_size = 0 ) return Section(bgcolor, hide, items, title, title_size) end diff --git a/src/items/block.jl b/src/items/block.jl index 1b80a54..9bdf6f5 100644 --- a/src/items/block.jl +++ b/src/items/block.jl @@ -1,4 +1,4 @@ -Image = Pair{AbstractString,AbstractString} +Image = Pair{AbstractString, AbstractString} """ paragraphs(args::String...) @@ -46,8 +46,8 @@ Construct a `Block` with paragraphs and an iframe. Block(paragraphs, iframe::String) = Block(paragraphs, Vector{Image}(), iframe) function to_html(section::Block) - full = - eltype(section.images) <: Union && isempty(section.iframe) ? "" : "medium-8 large-9" + full = eltype(section.images) <: Union && isempty(section.iframe) ? "" : + "medium-8 large-9" str = """
\n""" for p in section.paragraphs diff --git a/src/items/card.jl b/src/items/card.jl index 8e5ff79..633840e 100644 --- a/src/items/card.jl +++ b/src/items/card.jl @@ -27,7 +27,7 @@ end Construct a `Deck` with the cards in `args`. The `Deck` color can be set to: `card_blue`, `card_green`, `card_red`, `card_orange`, `card_julia_blue`, `card_julia_green`, `card_julia_purple`, `card_julia_red`. """ Deck(color::CardColor, args...) = Deck([card for card in args], color) -Deck(args...; color::CardColor=card_blue) = Deck([card for card in args], color) +Deck(args...; color::CardColor = card_blue) = Deck([card for card in args], color) function to_html(deck::Deck) color = color_to_card[deck.color] diff --git a/src/items/carousel.jl b/src/items/carousel.jl index e69de29..8b13789 100644 --- a/src/items/carousel.jl +++ b/src/items/carousel.jl @@ -0,0 +1 @@ + diff --git a/src/items/git.jl b/src/items/git.jl index f2ed2c2..6c431ee 100644 --- a/src/items/git.jl +++ b/src/items/git.jl @@ -1,4 +1,4 @@ -const RepoLabels = Union{String,Pair{String,Vector{String}}} +const RepoLabels = Union{String, Pair{String, Vector{String}}} """ GitRepo @@ -15,7 +15,7 @@ end Stores the URLs of git repositories and an associated filter. By default filters `"github-actions[bot]"`. """ -function GitRepo(args::RepoLabels...; filter=["github-actions[bot]"]) +function GitRepo(args::RepoLabels...; filter = ["github-actions[bot]"]) return GitRepo([r for r in args], filter) end @@ -84,8 +84,8 @@ function Git(gh_rl::RepoLabels, git_filter) gh = isa(gh_rl, Pair) ? gh_rl.first : gh_rl - r = GitHub.repo(gh; auth=myauth) - contributors = filter(c -> c ∉ git_filter, GitHub.contributors(gh; auth=myauth)[1]) + r = GitHub.repo(gh; auth = myauth) + contributors = filter(c -> c ∉ git_filter, GitHub.contributors(gh; auth = myauth)[1]) is_github = "github" ∈ keys(info) this_user = is_github ? lowercase(split(info["github"], "/")[end]) : "" @@ -138,7 +138,7 @@ function to_html(repos::GitRepo) if label ∉ keys(publication_labels) push!( publication_labels, - label => ColorLabel(mod(length(publication_labels), 22)), + label => ColorLabel(mod(length(publication_labels), 22)) ) end color = color_to_label[publication_labels[label]] diff --git a/src/items/publications.jl b/src/items/publications.jl index fb393d4..6e33805 100644 --- a/src/items/publications.jl +++ b/src/items/publications.jl @@ -14,7 +14,7 @@ end Import a bibliography from `source` using `parser`. Some sorting options can be given through `sort`. Please check the `Bibliography.jl` package. """ -function Publications(source::String; parser::Parser=bibtex, sort::FieldSort=required) +function Publications(source::String; parser::Parser = bibtex, sort::FieldSort = required) return Publications(parser, sort, joinpath(local_info["content"], source)) end @@ -84,7 +84,7 @@ function to_html(publications::Vector{Bibliography.Publication}) if label ∉ keys(publication_labels) push!( publication_labels, - label => ColorLabel(mod(length(publication_labels), 22)), + label => ColorLabel(mod(length(publication_labels), 22)) ) end color = color_to_label[publication_labels[label]] diff --git a/src/items/timeline.jl b/src/items/timeline.jl index 7c4ab43..dc51214 100644 --- a/src/items/timeline.jl +++ b/src/items/timeline.jl @@ -26,7 +26,7 @@ end Construct a `TimeLime` with the dots in `args`. The `TimeLine` color can be set to: `tl_blue`, `tl_green`, `tl_red`, `tl_orange`, `tl_julia_blue`, `tl_julia_green`, `tl_julia_purple`, `tl_julia_red`, `tl_julia`. """ TimeLine(color::TimeLineColor, args::Dot...) = TimeLine([dot for dot in args], color) -TimeLine(args::Dot...; color=tl_blue) = TimeLine([dot for dot in args], color) +TimeLine(args::Dot...; color = tl_blue) = TimeLine([dot for dot in args], color) function to_html(tl::TimeLine) str = """ diff --git a/src/page.jl b/src/page.jl index 4cfca72..470ea6c 100644 --- a/src/page.jl +++ b/src/page.jl @@ -10,10 +10,10 @@ struct Page title::String function Page( - background::BackgroundColor, - hide::Bool, - sections::Vector{<:AbstractSection}, - title::String, + background::BackgroundColor, + hide::Bool, + sections::Vector{<:AbstractSection}, + title::String ) return new(background, hide, sections, title) end @@ -29,10 +29,10 @@ Constructor for `Page`. - `title::String=""`: Page's title, can be left empty. """ function page(; - background::BackgroundColor=bg_grey, - hide::Bool=false, - sections::Vector{<:AbstractSection}=Vector{AbstractSection}(), - title::String="" + background::BackgroundColor = bg_grey, + hide::Bool = false, + sections::Vector{<:AbstractSection} = Vector{AbstractSection}(), + title::String = "" ) return content[title] = Page(background, hide, sections, title) end diff --git a/src/skeleton.jl b/src/skeleton.jl index ecba703..4a65e69 100644 --- a/src/skeleton.jl +++ b/src/skeleton.jl @@ -3,7 +3,7 @@ Generate the head section for a `page` given the global `info`. """ -function head(info::Dict{String,String}, page::String) +function head(info::Dict{String, String}, page::String) subtitle = page == "index" ? "homepage" : page return str = """ @@ -28,7 +28,7 @@ end Generate the navigation menu for a `page` given its `content`, and the global `info`. Please set `opt_in` to `true` to promote `StaticWebPages`. """ function nav( - info::Dict{String,String}, content::OrderedDict{String,Any}, page::String, opt_in::Bool + info::Dict{String, String}, content::OrderedDict{String, Any}, page::String, opt_in::Bool ) avatar = get(info, "avatar_shape", "round") == "raw" ? "avatar_raw" : "avatar_round" str = """ @@ -54,8 +54,8 @@ function nav( end end - str *= - "cv" ∈ keys(info) ? """\n
  • C.V.
  • \n""" : "" + str *= "cv" ∈ keys(info) ? """\n
  • C.V.
  • \n""" : + "" if "email" ∈ keys(info) if length(info["email"]) > 20 diff --git a/test/Aqua.jl b/test/Aqua.jl new file mode 100644 index 0000000..07cd9ba --- /dev/null +++ b/test/Aqua.jl @@ -0,0 +1,24 @@ +@testset "Aqua.jl" begin + # TODO: Fix the broken tests and remove the `broken = true` flag + Aqua.test_all( + StaticWebPages; + ambiguities = (broken = false,), + deps_compat = false, + piracies = (broken = false,) + ) + + @testset "Ambiguities: StaticWebPages" begin + Aqua.test_ambiguities(StaticWebPages;) + end + + @testset "Piracies: StaticWebPages" begin + Aqua.test_piracies(StaticWebPages;) + end + + @testset "Dependencies compatibility (no extras)" begin + Aqua.test_deps_compat( + StaticWebPages; + check_extras = false # ignore = [:Random] + ) + end +end diff --git a/test/ExplicitImports.jl b/test/ExplicitImports.jl new file mode 100644 index 0000000..d340955 --- /dev/null +++ b/test/ExplicitImports.jl @@ -0,0 +1,4 @@ +@testset "Look for Explicit Imports" begin + @test check_no_implicit_imports( + StaticWebPages; allow_unanalyzable = (StaticWebPages,)) === nothing +end diff --git a/test/JET.jl b/test/JET.jl new file mode 100644 index 0000000..efc5fea --- /dev/null +++ b/test/JET.jl @@ -0,0 +1,3 @@ +@testset "Code linting (JET.jl)" begin + JET.test_package(StaticWebPages; target_defined_modules = true) +end diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 0c36332..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,2 +0,0 @@ -[deps] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/TestItemRunner.jl b/test/TestItemRunner.jl new file mode 100644 index 0000000..cf86c5a --- /dev/null +++ b/test/TestItemRunner.jl @@ -0,0 +1,3 @@ +@testset "TestItemRunner" begin + @run_package_tests +end diff --git a/test/internal.jl b/test/internal.jl new file mode 100644 index 0000000..2d3119a --- /dev/null +++ b/test/internal.jl @@ -0,0 +1,34 @@ +@testset "StaticWebPages.jl" begin + rm("build"; recursive = true, force = true) + mkdir("build") + include("run.jl") + + # Personal file existence + @test isfile("build/index.html") + @test isfile("build/publications.html") + @test isfile("build/research.html") + @test isfile("build/software.html") + + @test isfile("build/img/bmilp.png") + @test isfile("build/img/cs.png") + @test isfile("build/img/knowledge.png") + @test isfile("build/img/pic.jpg") + + @test isfile("build/files/bae2018gapplanar.pdf") + @test isfile("build/files/baffier2017hanabi.pdf") + @test isfile("build/files/baffier2018experimental.pdf") + @test isfile("build/files/cv.pdf") + @test isfile("build/files/parmentier2019introducing.pdf") + @test isfile("build/files/richoux2016ghost.pdf") + + # Template file existence + @test isfile("build/css/app.css") + @test isfile("build/css/foundation.min.css") + + @test isfile("build/js/app.js") + @test isfile("build/js/vendor/foundation.min.js") + @test isfile("build/js/vendor/jquery.js") + @test isfile("build/js/vendor/what-input.js") + + rm("build"; recursive = true) +end diff --git a/test/run.jl b/test/run.jl index 4954065..859d39b 100644 --- a/test/run.jl +++ b/test/run.jl @@ -15,7 +15,7 @@ local_info["server"] = "server_address" # `rm_dir = true` will clean up the site folder before generating it again. Default to false. # `opt_in = true` will a link to this generator website in the side menu. Default to false. -StaticWebPages.export_site(; d=local_info, rm_dir=true, opt_in=true) +StaticWebPages.export_site(; d = local_info, rm_dir = true, opt_in = true) ## upload website (comment/delete if not needed) # unfortunately does not work yet on windows system, please sync manually for the moment diff --git a/test/runtests.jl b/test/runtests.jl index f11e212..800dd23 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,37 +1,15 @@ using StaticWebPages -using Test - -@testset "StaticWebPages.jl" begin - rm("build"; recursive=true, force=true) - mkdir("build") - include("run.jl") - - # Personal file existence - @test isfile("build/index.html") - @test isfile("build/publications.html") - @test isfile("build/research.html") - @test isfile("build/software.html") - - @test isfile("build/img/bmilp.png") - @test isfile("build/img/cs.png") - @test isfile("build/img/knowledge.png") - @test isfile("build/img/pic.jpg") - @test isfile("build/files/bae2018gapplanar.pdf") - @test isfile("build/files/baffier2017hanabi.pdf") - @test isfile("build/files/baffier2018experimental.pdf") - @test isfile("build/files/cv.pdf") - @test isfile("build/files/parmentier2019introducing.pdf") - @test isfile("build/files/richoux2016ghost.pdf") - - # Template file existence - @test isfile("build/css/app.css") - @test isfile("build/css/foundation.min.css") - - @test isfile("build/js/app.js") - @test isfile("build/js/vendor/foundation.min.js") - @test isfile("build/js/vendor/jquery.js") - @test isfile("build/js/vendor/what-input.js") - - rm("build"; recursive=true) +using Aqua +using ExplicitImports +using JET +using Test +using TestItemRunner + +@testset "Package tests: StaticWebPages" begin + include("internal.jl") + include("Aqua.jl") + include("ExplicitImports.jl") + include("JET.jl") + include("TestItemRunner.jl") end