Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion ext/HealthBaseDrWatsonExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,44 @@ The study environment remains activated for you to immediately add packages.

- `template::Symbol` - A template option specifying the structure of the the study. Available templates can be found by running `@doc(study_template)`.

- `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.

# Example

```julia-repl
julia> initialize_study("Cardiooncology", "Jacob S. Zelko, Jakub Mitura"; github_name = "TheCedarPrince", template=:observational)
```
"""
function HealthBase.initialize_study(path, authors = nothing; template::Symbol = :default)
function HealthBase.initialize_study(path, authors = nothing; github_name = "PutYourGitHubNameHere", template::Symbol = :default)
tpl = study_template(template).template
ftg = study_template(template).folders_to_gitignore

if github_name == "PutYourGitHubNameHere"
@warn """
`github_name` is not specified. Docs will not be deployed.

To host the docs online, set the keyword `github_name` with the name of the GitHub account
you plan to upload at, and then manually enable the `gh-pages` deployment by going to
settings/pages of the GitHub repo, and choosing as "Source" the `gh-pages` branch.

You can skip this prompt by specifying `github_name` in the function call. For example:
`initialize_study("MyStudy", "Carlos", github_name = "JuliaHealth")`
"""

print("Enter the name of your GitHub account (leave empty to skip): ")
input = readline()

github_name = isempty(input) ? github_name : input
end

initialize_project(
path;
authors = authors,
template = tpl,
folders_to_gitignore = ftg,
force = true,
add_docs = true,
github_name = github_name
)
cd(path)
end
Expand Down
24 changes: 21 additions & 3 deletions test/drwatsonext.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
cd(@__DIR__)

github_name = "foo"
path = "test_study"

initialize_study(path; template = :observational)
@test_warn "" initialize_study(path; template = :llm);

cd("..")
rm("test_study", recursive = true, force = true)

mktemp() do fname, f
write(f, "X")
seek(f, 0)
redirect_stdin(f) do
@test initialize_study(path; template = :llm) == nothing
end
end

cd("..")
rm("test_study", recursive = true, force = true)

initialize_study(path; github_name = github_name, template = :observational)
quickactivate(path)

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

initialize_study(path; template = :llm)
initialize_study(path; github_name = github_name, template = :llm)
quickactivate(path)

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

@test_throws ErrorException initialize_study(path; template = :foobar)
@test_throws ErrorException initialize_study(path; github_name = github_name, template = :foobar)

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

Expand Down
Loading