Skip to content

Commit

Permalink
Merge pull request #124 from AP6YC/docs-assets
Browse files Browse the repository at this point in the history
Docs assets
  • Loading branch information
AP6YC authored May 4, 2023
2 parents bd9d04a + b4987eb commit 059be15
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DemoCards = "311a05b2-6137-4a5a-b473-18580a3d38b5"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MLDataUtils = "cc2ba9b6-d476-5e6d-8eaf-a92d5412d41d"
MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458"
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
Expand Down
47 changes: 43 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
make.jl
# Description
This file builds the documentation for the AdaptiveResonance.jl package
using Documenter.jl and other tools.
"""
Expand All @@ -12,12 +13,17 @@ using Documenter.jl and other tools.
using
Documenter,
DemoCards,
Logging,
Pkg

# -----------------------------------------------------------------------------
# SETUP
# -----------------------------------------------------------------------------

# Common variables of the script
PROJECT_NAME = "AdaptiveResonance"
DOCS_NAME = "docs"

# Fix GR headless errors
ENV["GKSwstype"] = "100"

Expand All @@ -27,10 +33,10 @@ current_dir = basename(pwd())

# If using the CI method `julia --project=docs/ docs/make.jl`
# or `julia --startup-file=no --project=docs/ docs/make.jl`
if occursin("AdaptiveResonance", current_dir)
if occursin(PROJECT_NAME, current_dir)
push!(LOAD_PATH, "../src/")
# Otherwise, we are already in the docs project and need to dev the above package
elseif occursin("docs", current_dir)
elseif occursin(DOCS_NAME, current_dir)
Pkg.develop(path="..")
# Otherwise, building docs from the wrong path
else
Expand All @@ -53,17 +59,25 @@ end

# Point to the raw FileStorage location on GitHub
top_url = raw"https://media.githubusercontent.com/media/AP6YC/FileStorage/main/AdaptiveResonance/"

# List all of the files that we need to use in the docs
files = [
"header.png",
"art.png",
"artmap.png",
"ddvfa.png",
]
# Make a destination for the files
download_folder = joinpath("src", "assets", "downloads")

# Make a destination for the files, accounting for when folder is AdaptiveResonance.jl
assets_folder = joinpath("src", "assets")
if basename(pwd()) == PROJECT_NAME || basename(pwd()) == PROJECT_NAME * ".jl"
assets_folder = joinpath(DOCS_NAME, assets_folder)
end

download_folder = joinpath(assets_folder, "downloads")
mkpath(download_folder)
download_list = []

# Download the files one at a time
for file in files
# Point to the correct file that we wish to download
Expand All @@ -75,6 +89,21 @@ for file in files
# If the file isn't already here, download it
if !isfile(dest_file)
download(src_file, dest_file)
@info "Downloaded $dest_file, isfile: $(isfile(dest_file))"
else
@info "File already exists: $dest_file"
end
end

# Downloads debugging
detailed_logger = Logging.ConsoleLogger(stdout, Info, show_limited=false)
with_logger(detailed_logger) do
@info "Current working directory is $(pwd())"
@info "Assets folder is:" readdir(assets_folder, join=true)
# full_download_folder = joinpath(pwd(), "src", "assets", "downloads")
@info "Downloads folder exists: $(isdir(download_folder))"
if isdir(download_folder)
@info "Downloads folder contains:" readdir(download_folder, join=true)
end
end

Expand All @@ -90,6 +119,16 @@ assets = [
joinpath("assets", "favicon.ico"),
]

# @info "Favicon?"
# @info isfile(joinpath("assets", "favicon.ico"))

# # Add the downloaded files to the assets list
# for file in files
# local_file = joinpath("assets", "downloads", file)
# @info isfile(local_file)
# push!(assets, local_file)
# end

# if there are generated css assets, pass it to Documenter.HTML
isnothing(demo_assets) || (push!(assets, demo_assets))

Expand Down
1 change: 1 addition & 0 deletions docs/serve.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
serve.jl
# Description
Convenience script that serves the locally built documentation.
"""

Expand Down

0 comments on commit 059be15

Please sign in to comment.