Skip to content

Commit 3258bce

Browse files
Enable documentation creation and specify hosting location (#37)
* Enabled documentation creation in initialize_study * Added configuration for github_name and updated tests/docs * Added tests for user input into initialize study
1 parent d0e828f commit 3258bce

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

ext/HealthBaseDrWatsonExt.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,44 @@ The study environment remains activated for you to immediately add packages.
185185
186186
- `template::Symbol` - A template option specifying the structure of the the study. Available templates can be found by running `@doc(study_template)`.
187187
188+
- `github_name::String` - the GitHub account you intend to host documentation at. You will need to manually enable the `gh-pages` deployment by going to settings/pages of the GitHub study repo, and choosing as "Source" the `gh-pages` branch. If a name is not specified, a prompt will appear.
189+
190+
# Example
191+
192+
```julia-repl
193+
julia> initialize_study("Cardiooncology", "Jacob S. Zelko, Jakub Mitura"; github_name = "TheCedarPrince", template=:observational)
194+
```
188195
"""
189-
function HealthBase.initialize_study(path, authors = nothing; template::Symbol = :default)
196+
function HealthBase.initialize_study(path, authors = nothing; github_name = "PutYourGitHubNameHere", template::Symbol = :default)
190197
tpl = study_template(template).template
191198
ftg = study_template(template).folders_to_gitignore
192199

200+
if github_name == "PutYourGitHubNameHere"
201+
@warn """
202+
`github_name` is not specified. Docs will not be deployed.
203+
204+
To host the docs online, set the keyword `github_name` with the name of the GitHub account
205+
you plan to upload at, and then manually enable the `gh-pages` deployment by going to
206+
settings/pages of the GitHub repo, and choosing as "Source" the `gh-pages` branch.
207+
208+
You can skip this prompt by specifying `github_name` in the function call. For example:
209+
`initialize_study("MyStudy", "Carlos", github_name = "JuliaHealth")`
210+
"""
211+
212+
print("Enter the name of your GitHub account (leave empty to skip): ")
213+
input = readline()
214+
215+
github_name = isempty(input) ? github_name : input
216+
end
217+
193218
initialize_project(
194219
path;
195220
authors = authors,
196221
template = tpl,
197222
folders_to_gitignore = ftg,
198223
force = true,
224+
add_docs = true,
225+
github_name = github_name
199226
)
200227
cd(path)
201228
end

test/drwatsonext.jl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
cd(@__DIR__)
2+
3+
github_name = "foo"
24
path = "test_study"
35

4-
initialize_study(path; template = :observational)
6+
@test_warn "" initialize_study(path; template = :llm);
7+
8+
cd("..")
9+
rm("test_study", recursive = true, force = true)
10+
11+
mktemp() do fname, f
12+
write(f, "X")
13+
seek(f, 0)
14+
redirect_stdin(f) do
15+
@test initialize_study(path; template = :llm) == nothing
16+
end
17+
end
18+
19+
cd("..")
20+
rm("test_study", recursive = true, force = true)
21+
22+
initialize_study(path; github_name = github_name, template = :observational)
523
quickactivate(path)
624

725
@test cohortsdir() == abspath("data", "cohorts")
@@ -12,7 +30,7 @@ quickactivate(path)
1230
cd("..")
1331
rm("test_study", recursive = true, force = true)
1432

15-
initialize_study(path; template = :llm)
33+
initialize_study(path; github_name = github_name, template = :llm)
1634
quickactivate(path)
1735

1836
@test corpusdir() == abspath("data", "corpus")
@@ -28,7 +46,7 @@ quickactivate(path)
2846
cd("..")
2947
rm("test_study", recursive = true, force = true)
3048

31-
@test_throws ErrorException initialize_study(path; template = :foobar)
49+
@test_throws ErrorException initialize_study(path; github_name = github_name, template = :foobar)
3250

3351
STUDY_TEMPLATES = Base.get_extension(HealthBase, :HealthBaseDrWatsonExt).STUDY_TEMPLATES
3452

0 commit comments

Comments
 (0)