janet-lang / janet-lang.org

Website for janet
https://janet-lang.org
MIT License
90 stars 59 forks source link

Add @-prefixed import section #213

Closed sogaiu closed 5 months ago

sogaiu commented 7 months ago

This PR is an attempt to address #208.

It adds a section to the Modules page for @-prefixed imports.

The text is close to:

@-prefixed Imports

Starting in 1.26.0, Janet allows importing modules from 
custom directories more easily using the @-prefix in a 
module path.

For example, if there is a dynamic binding 
:custom-modules that is a file system path to a 
directory of modules, import from that directory with:

(import @custom-modules/mymod)

As a special case, it is possible to import from 
absolute paths by prefixing an absolute path with @. 
For example, to import from 
/tmp/custom-modules/mymod.janet, express this as:

(import @/tmp/custom-modules/mymod)

Note that although using absolute paths is possible 
and useful for testing, it is not recommended for 
most production use cases. 

Details of the investigation that factored into the content start in this comment.


There was also some reformatting for making line lengths kinder for folks who don't use (or have trouble using) very wide screens (or multiple displays). This makes it easier to do side-by-side comparisons. If these sorts of edits are a problem, I can undo them.