Skip to content

How to create a new Julia package

Eric Neiva edited this page Feb 14, 2023 · 23 revisions

PkgTemplates is a Julia package for creating new Julia packages in an easy, repeatable, and customizable way.

We provide here a short outline of the usage of this package, originally referring to v.0.7.6, but still working for v.0.7.31.

NOTE: PkgTemplates usage has significantly varied compared to versions older than v.0.7. You can review the main changes at Migrating To PkgTemplates 0.7+.

Package installation and usage

Read carefully the User guide, especially the sections Template and Plugins.

Gridap.jl recommended template for v.0.7.6

    julia> import Pkg; Pkg.add("PkgTemplates")
    julia> using PkgTemplates
    julia> t = Template(;
            user="gridap",
            authors=["Your name <your-email>"],
            dir=pwd(),
            julia=v"1.7",
            plugins=[
                License(; name="MIT", path=nothing, destination="LICENSE.md"),
                CompatHelper(),
                Codecov(),    
                GitHubActions(;
                osx=false,
                windows=false,
                ),
                Documenter{GitHubActions}(),
                Git(;
                    ignore=["*.jl.*.cov",
                            "*.jl.cov",
                            "*.jl.mem",
                            "*.code-workspace",
                            ".DS_Store",
                            "docs/build/",
                            "Manifest.toml",
                            "tmp/"],
                    ssh=true
                ),
            ],
        )
    julia> t("myPkg")

OBSERVATIONS

  1. The above configuration will create a package named myPkg on the pwd() folder with a standard MIT license (the same one as gridap).
  2. The user field of the template must be set to the organisation name. For instance, for Gridap packages to be published in the Gridap organisation we must set user="gridap". It becomes clear why in point 3.
  3. The above configuration also initialises a git repository at the myPkg folder. If you change directory to myPkg and run git remote -v, you should see that origin's remote URL is set to [email protected]:gridap/myPkg.jl.git (ready to be published).

Create a documentation template

Documenter is a julia package for building documentation of julia projects.

Official Documenter web page contains enough and clear information on how to create and develop documentation for julia projects.

In this section we only enumerate the required steps to create from scratch a [Documenter] project in order to enable automatic documentation deployment for GitHub hosted projects using GitHub Actions.

  1. Setup the folder structure (+info)
  2. Edit the make.jl julia file to enable automatic deployment throught GitHub Pages (gh-pages branch) (+info)