Workflow of Writing a Package¶
Start with Empty¶
$ julia1.7
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.0 (2021-11-30)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(@v1.7) pkg> generate MonoDecomp.jl
Generating project MonoDecomp:
MonoDecomp.jl/Project.toml
MonoDecomp.jl/src/MonoDecomp.jl
julia>
Starting with existing folder¶
- create a github repo, say
xfun.jl
- open a Julia session, and then run
] generate xfun.jl
, which will generate a subfolderxfun.jl
, obtain the resultingProject.toml
, and wrap the source code by module as shown in the generated codesrc/xfun.jl
. - discard the generated
xfun.jl
subfolder. - two choices for adding dependencies for testing
- use
extras
andtargets
- use
test/Project.toml
- use
- register package: follow the instruction at https://github.com/JuliaRegistries/General#registering-a-package-in-general
- via the web interface: login with GitHub account, and then fill the form.
- via https://github.com/JuliaRegistries/Registrator.jl
- first click
install app
, then follow the instruction to grant the access to which repo. - comment
@JuliaRegistrator register
in the commit to be register
- first click
Develop/Debug Locally¶
- install the package via
dev ABSOLUTE_PATH
(usually inv1.x
env). The absolute path (not relative path) can allow the installed package to be found starting from everywhere instead of the “relative” project. - make any changes on the source code, NO need to run
dev
again, the update will be automatically synced. test PACKAGE_NAME
(usually inv1.x
env) would running the tests- activate the
docs
env, and runinclude("make.jl")
, then open a http server,python3 -m http.server 8080
under thebuild/
folder
NOT add LOCAL_PACKAGE
Although the package can be installed, but the version is also controlled by git, that is, a uncommitted version cannot be updated.
In that case, a new commit is also not automatically installed. up LOCAL_PACKAGE
is necessary. Just imagine that adding package in this way is almost like to add packages remotely.
Example
refer to