Open choldgraf opened 5 years ago
It's so awesome you are exploring this !! funny enough @choldgraf i did a quick search today and found this nbreport tool on pypi by accident. So it might not be a bad idea to reconsider the name it you want it on pip eventually. :)
my apologies. I don't fully understand what you mean by offloading authoring tools into the metadata. BUT i can tell you that rmarkdown supports references too. The way they handle refs is in the markdown text however combined with bib info in the first "cell" of the markdown file via a yaml list. So when the file is parsed, it looks at the yaml, gets the bib tex list of references and connects those references with what is cited in the markdown inline. All this requires then is a yaml cell at the top to define stuff (for references).
So without knowing quite enough. i think that it would be wonderful to see some structure that would make is easy and standard to add on to the potential for authoring tools. ie someone might mirror the refs in rmarkdown for jupyter . I could see that structure being something at the top of the notebook where you could define stuff that everyone used. so this would come from jupyter. It could accept css, refs or whatever peopel envision.Or maybe the top cell has a toolbar that allows you to easily build out metadata in json format? Then yes some sort of way to access the metadata to build out functionality as needed on top of some basic report authoring tools like
And make it all easy to do rather than having to dig into the metadata itself. This might be what you're suggesting above already! and i hope i'm not too off track here! just my thoughts. this is so so cool.
FWIW, this tool already does numbers 1 and 3. It doesn't yet allow for 2 but that should be easy. The main question there is how you let people specify a CSS file. It's easy enough if you're doing it from the command-line but what about from the UI (e.g. do you look for a "css_file" metadata, do you use an environment variable, etc)
got it! So i think the discussion of adding a css file aligns with references, etc.
---
title: "My Report"
author: "First Lastname"
output:
html_document:
toc: true
number_sections: true
theme: united
highlight: tango
---
or
---
title: "My Report"
output:
html_document:
css: styles.css
refs: bib.tex
---
You and @betatim might have some clever ideas. @mbjoseph might have some ideas too! i'll keep thinking about it but it needs to be simple but with a structure that people can do other things with. (as you have already suggested) :) In the above you can see how they build out more complex documents using various yaml items. so we just need space for that to happen.
NOTE that R has lots of templates that the community developed using css once this fairly simple structure was available. :) i can see this exploding with jupyter too!
docs in case this is of interest. i know this is Jupyter but just so you can see. here
one question: could you use RMarkdown for writing python code? Is it only for R?
If no, then couldn't we just generate an RMarkdown file from the jupyter notebook, then run RMarkdown on it to generate HTML?
R Markdown can be used with python for sure. With the reticulate package you can even use conda and virtualenv: https://cran.r-project.org/web/packages/reticulate/vignettes/r_markdown.html
Just pushed an edit to this repo that lets you give a custom CSS rule. You can either call this from the command line with nbreport --css path/to/file.css
or if a notebook has css_extra: 'path/to/file.css'
then the button download will work too
oh R markdown does support other kernels including bash. Here has been the sticking point for me (and i think it's been a while since i've tried so it could be better). I was never able to get R markdown to find the right python kernel. R markdown needs to run the code and build the outputs. So it's not like jupyter where you can export a notebook as is OR run it then export. this could be a good time to poll the community on this too. For me in a class for instance i need things to work consistently and using several tools is challenging. BUT rmarkdown has a TON of authoring flexibility built into it. it's awesome!
if you went this route would you be able to add this setup to a jupyter hub / binder config?
@mbjoseph have you actually gotten rmd to easily find different environments? Like i said i haven't tried in a while. maybe a year or more even!! last time i tried i spent forever trying to get it to find my ea-python kernel.
Is this -- css_extra: 'path/to/file.css'
Metadata in the first cell @choldgraf ? I’m going to play with this but maybe not till tomorrow or later. So very excited to have this for notebooks.
it's in the metadata for the notebook itself (each notebook has a top-level metadata section, and each cell also has its own metadata section)
also pinging @emdupre who was also interested in a single-page report-generation tool.
@lwasser yes - I put together a little example that uses our earthpy-dev conda environment and plots the Rocky Mountain National Park RGB GeoTIFF using the earthpy.spatial.plot_rgb
function: https://gist.github.com/mbjoseph/4f0269d741bec91977bfb0efc6eaf6c8
Works like a charm locally, but curious to know whether it works for you too (assuming that the reticulate package is installed, along with our earthpy-dev
conda env).
R Markdown support has matured considerably in the past year, so it's possible that it is easier now to use than when you last tried!
I just had a thought - perhaps this repository could be an experiment in offloading as much of the authoring tools as possible onto the notebook metadata (as opposed to requiring a markdown flavor that supports references etc...I think that'll happen at some point but who knows when).
For example, one could imagining parsing the notebook cell metadata for a
references
field. You could collect all the references in a unique list, as well as a set of pointers for which cells contained those references, then auto-generated a bibliography at the bottom with some nice HTML to the side of the rendered cell.Perhaps this tool could be
nbauthor
, and a bit more expansive than just generating a report.@betatim @lawasser any thoughts on that? Is this an issue worth pushing a bit further?