-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
make.jl
146 lines (126 loc) · 4.51 KB
/
make.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
"""
make.jl
This file builds the documentation for the AdaptiveResonance.jl package
using Documenter.jl and other tools.
"""
# -----------------------------------------------------------------------------
# DEPENDENCIES
# -----------------------------------------------------------------------------
using
Documenter,
DemoCards,
Pkg
# -----------------------------------------------------------------------------
# SETUP
# -----------------------------------------------------------------------------
# Fix GR headless errors
ENV["GKSwstype"] = "100"
# Get the current workind directory's base name
current_dir = basename(pwd())
@info "Current directory is $(current_dir)"
# 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)
push!(LOAD_PATH, "../src/")
# Otherwise, we are already in the docs project and need to dev the above package
elseif occursin("docs", current_dir)
Pkg.develop(path="..")
# Otherwise, building docs from the wrong path
else
error("Unrecognized docs setup path")
end
# Inlude the local package
using AdaptiveResonance
# using JSON
if haskey(ENV, "DOCSARGS")
for arg in split(ENV["DOCSARGS"])
(arg in ARGS) || push!(ARGS, arg)
end
end
# -----------------------------------------------------------------------------
# DOWNLOAD LARGE ASSETS
# -----------------------------------------------------------------------------
# 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")
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
src_file = top_url * file * "?raw=true"
# Point to the correct local destination file to download to
dest_file = joinpath(download_folder, file)
# Add the file to the list that we will append to assets
push!(download_list, dest_file)
# If the file isn't already here, download it
if !isfile(dest_file)
download(src_file, dest_file)
end
end
# -----------------------------------------------------------------------------
# GENERATE
# -----------------------------------------------------------------------------
# Generate the demo files
# this is the relative path to docs/
demopage, postprocess_cb, demo_assets = makedemos("examples")
assets = [
joinpath("assets", "favicon.ico"),
]
# if there are generated css assets, pass it to Documenter.HTML
isnothing(demo_assets) || (push!(assets, demo_assets))
# Make the documentation
makedocs(
modules=[AdaptiveResonance],
format=Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true",
assets = assets,
),
pages=[
"Home" => "index.md",
"Getting Started" => [
"getting-started/whatisart.md",
"getting-started/basic-example.md",
],
"Tutorial" => [
"Guide" => "man/guide.md",
demopage,
# "Examples" => "man/examples.md",
"Modules" => "man/modules.md",
"Contributing" => "man/contributing.md",
"Index" => "man/full-index.md",
"Internals" => "man/dev-index.md",
],
],
repo="https://github.com/AP6YC/AdaptiveResonance.jl/blob/{commit}{path}#L{line}",
sitename="AdaptiveResonance.jl",
authors="Sasha Petrenko",
# assets=String[],
)
# 3. postprocess after makedocs
postprocess_cb()
# a workdaround to github action that only push preview when PR has "push_preview" labels
# issue: https://github.com/JuliaDocs/Documenter.jl/issues/1225
# function should_push_preview(event_path = get(ENV, "GITHUB_EVENT_PATH", nothing))
# event_path === nothing && return false
# event = JSON.parsefile(event_path)
# haskey(event, "pull_request") || return false
# labels = [x["name"] for x in event["pull_request"]["labels"]]
# return "push_preview" in labels
# end
# -----------------------------------------------------------------------------
# DEPLOY
# -----------------------------------------------------------------------------
deploydocs(
repo="github.com/AP6YC/AdaptiveResonance.jl.git",
devbranch="develop",
# push_preview = should_push_preview(),
)