Assume we are developing a package called MyPkg. Step 3 of this tutorial states that, in order to export our package functions, we should add the following to our src/MyPkg.jl file:
- A statement
export my_function - A statement
include("file_with_functions.jl")
Fair enough. However, in a complex package, we may have many inter-dependent files. Say our src folder has files A.jl and B.jl, and say B.jl uses functions from A.jl and thus contains the statement include("A.jl").
Following the instructions of the tutorial, we should write the following in our MyPkg.jl file:
export first_function_of_A
...
export last_function_of_A
export first_function_of_B
...
export last_function_of_B
include("A.jl")
include("B.jl")
However, since B.jl already has an expression include("A.jl"), this leads to a double evaluation of this expression. When importing the package, we will get Warning: Replacing docs for... for all functions of A.jl.
What is the best practice for structuring the MyPkg.jl file in the context of multiple files, some of which source (include) others? The practice should not only avoid repeated calls to include but ensure that everything is exported in the package.
Thanks!