Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid the python prompt in some cells? #7

Open
FrancescAlted opened this issue Feb 6, 2018 · 1 comment
Open

Avoid the python prompt in some cells? #7

FrancescAlted opened this issue Feb 6, 2018 · 1 comment

Comments

@FrancescAlted
Copy link

Hi. I am starting to use nb2plots and I generally like it. I have a question though. Is there a way to get code cells rendered without the python prompts (>>> and ...)?

For example, when I use this cell:

%%writefile myconf.yaml
root_dir: FPSIM
input_format: namelist
releases:
    tstart: "2015-01-01"
    tend: "2017-01-01"
    freq: 3H
    emissions:
        class: Station
        comment_prefix: Finse
        release_type: point
        release_point:
            lat: 60.594
            lon: 7.527
            elv: 1210.

It gets rendered as:

image

which is not what I want. In fact, the notebook renders it like:

image

which is closer to what I want. Hints?

@matthew-brett
Copy link
Owner

I'm afraid this is a fundamental limitation of nb2plots, at the moment. It converts all code cells to doctest format code blocks, and pays no attention to things like magics. So, in practice, you can't make this cell executable from the nb2plots .rst file, or convert it to an executable cell when rebuilding the notebook.

For now, what I would do, is work out some other way that doesn't use the magic, maybe something like:

# Write the myconf.yaml file.
open('myconf.yaml', 'wt') as fobj: fobj.write("""\
root_dir: FPSIM
input_format: namelist
releases:
    tstart: "2015-01-01"
    tend: "2017-01-01"
    freq: 3H
    emissions:
        class: Station
        comment_prefix: Finse
        release_type: point
        release_point:
            lat: 60.594
            lon: 7.527
""")

I'm in the process of thinking how to preserve the notebook cell contents in the .rst document, and use the Jupyter machinery to execute the cells, and return the output, but I haven't started that yet. I'm hoping to get that done in the next few weeks, but no promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants