Comments (8)
My personal opinion is that it is quite nice that Literate files are actual julia files. Also, the API of Pkg is arguably the "official" way of interacting with the package manager from scripts while the REPL mode is for interactive use and tries to have a "do what I mean" philosophy.
from literate.jl.
Right, that kinda emulates the pkg>
prompt too, and works without any changes.
from literate.jl.
Yea I have thought about that too. And same with ?
which could splice in a docstring.
from literate.jl.
Shell mode via ;
would be nice too, if that doesn't work already.
from literate.jl.
On second thought, this would deviate from one of the original ideas with the package, that the source files should be valid julia code. There exist functional API's for Pkg, docs and shell so maybe better to use those?
Also, why do you want to invoke Pkg in the files? Would it be better with an option to instantiate a provided Project.toml and running the script in that environment instead?
from literate.jl.
There are various reasons you might want to do this, for example if you want to make notebook-based tutorials for the package manager. I take the point about valid Julia code, but having this certainly doesn't prevent people from doing that, and given the various issues with notebooks it's reasonable to want to use Literate even if notebooks are the only valid target.
To elaborate a bit on our particular use case: We are doing exactly what you suggest, but just automating the process by adding ] activate .; instantiate
to the header of the script (during notebook preprocessing). We could well use the Pkg API for that, but especially for new users I'd prefer to avoid presenting a non-standard way of using the package manager.
from literate.jl.
Fair enough, although I wouldn't call
using Pkg
Pkg.activate(".")
Pkg.instantiate()
a "non-standard way" of using the package manager, it is actually the prefered method of using Pkg in scripts. Using ]
in notebooks looks kinda weird, and there is no indication of that you are invoking the package manager (since you don't get the pkg>
prompt etc.). Compare e.g.
IMO the first one is much more clear on what is going on. Note also that you can't copy-paste e.g. ]status
and have that work in the REPL. Personally I would use the functional interface to Pkg in notebooks but...
from literate.jl.
You can also use the Pkg string macro pkg"instantiate"
.
from literate.jl.
Related Issues (20)
- Multiline string and `#` HOT 2
- How to auto-generate README from literate script HOT 4
- Language-agnostic
- Inconsistent Documenter rendering between code execution in Literate.jl and Documenter.jl HOT 2
- Upvote for making main branch name configurable like in Documenter HOT 1
- Interploation into md-strings HOT 2
- use compact mode when printing by default HOT 3
- embed svg instead of png for plot HOT 2
- Allow AbstractDict config HOT 1
- How to create jupyter's raw type of cells? HOT 3
- How to properly caputure LaTeXString output in markdown output? HOT 4
- Support for Configuration per Code Block HOT 7
- Passphrase for my SSH key HOT 1
- Literate will ask for SSH passphrase multiple times HOT 1
- Escaping link interpretation for Documenter links HOT 3
- FR: Output to Quarto markdown flavour HOT 3
- Option to capture errors? HOT 1
- FR: Supporting flavor-specific filtering
- consecutive (or custom) image filenames HOT 6
- suggestion: mention MarkdownTables.jl in the manual HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from literate.jl.