An unofficial example of Julia package generated by PkgTemplates.jl
pkg> add PkgTemplates.jl
That is O.K.
Make julia script to generate package as follow:
#initialize.jl
using PkgTemplates
t = Template(;
ssh=true,
plugins=[
TravisCI(),
Codecov(),
GitHubPages(),
],
)
generate(t, "MySample")
If you use git with HTTPS protocol, set argument ssh=false
.
- Run this script:
$ julia initialize.jl
~/.julia/dev/MySample
will be generated.
-
Note that,
MySample
will be added default julia environment which means you can useusing MySample
without doingpkg>activate .
,using .MySample
or something like that. Some will says this feature is (in)convenient.- If you would like to move
MySample
to another directory, you shold dopkg> rm MySample
in advance.
- If you would like to move
-
Make your GitHub repository named
MySample.jl
. Do notInitialize this repository with a README
. just pushCreate repository
button. -
Push your repository
~/.julia/MySample
$ cd ~/.julia/dev/MySample
$ git remote -v
origin git@github.com:<your github account>/MySample.jl.git (fetch)
origin git@github.com:<your github account>/MySample.jl.git (push)
$ git push -u origin master
-
If you add
GitHubPages()
as element of list which assigns optional argumentplugins
, the folder nameddocs
will be generated at root repository you created.docs/make.jl
is julia script to generate documentation of your package using Documenter.jl. If you would like to documentation manually, you can refer this page. -
Once create your nice documentation, you can build it locally by using following commands:
$ ls
LICENSE Manifest.toml Project.toml README.md REQUIRE docs src test
$ julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
$ cd docs/build
$ python3 -m http.server --bind localhost
- Open web brouser and go to
localhost:8000
. You will see your page like this.
- Prepare GitHub account and Travis
- Read this article: Hosting Documentation(Documenter.jl)
- Generate SSH keys by DocumenterTool and copy them GitHub and Travis respectively. See
- Make sure
.travis.yml
contains the following code snippets which will be created automatically by PkgTemplates.
jobs:
include:
- stage: Documentation
julia: 1.1
script: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
after_success: skip
-
Go to
https://github.com/<your-github-username>/YourPackage.jl/settings
and enable github page so that your GitHub Pages site is currently being built from thegh-pages
branch. -
start Travis CI to build your documentation as github page. Build bot of TravisCI will push your documentation to
gh-pages
automatically like this
That's all. What you have to do is enjoy julia.