Code Monkey home page Code Monkey logo

Comments (8)

KristofferC avatar KristofferC commented on May 24, 2024 2

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.

fredrikekre avatar fredrikekre commented on May 24, 2024 1

Right, that kinda emulates the pkg> prompt too, and works without any changes.

from literate.jl.

fredrikekre avatar fredrikekre commented on May 24, 2024

Yea I have thought about that too. And same with ? which could splice in a docstring.

from literate.jl.

MikeInnes avatar MikeInnes commented on May 24, 2024

Shell mode via ; would be nice too, if that doesn't work already.

from literate.jl.

fredrikekre avatar fredrikekre commented on May 24, 2024

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.

MikeInnes avatar MikeInnes commented on May 24, 2024

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.

fredrikekre avatar fredrikekre commented on May 24, 2024

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.

screenshot from 2018-10-24 10-59-55

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.

KristofferC avatar KristofferC commented on May 24, 2024

You can also use the Pkg string macro pkg"instantiate".

from literate.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.