-
Notifications
You must be signed in to change notification settings - Fork 663
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
[WIP] adding a CLI to generate books #89
Conversation
1bc35ac
to
355185f
Compare
Anybody know what is the best way to ensure that a folder is copied over when you pip install something? I need to install the CLI which is in 'jupyter-book' but also have access to the template in 'book_template' |
I think package_data would do that.
See
https://github.com/uwescience/shablona/blob/master/setup.py
…On Fri, Jan 25, 2019 at 3:09 PM Chris Holdgraf ***@***.***> wrote:
Anybody know what is the best way to ensure that a folder is copied over
when you pip install something? I need to install the CLI which is in
'jupyter-book' but also have access to the template in 'book_template'
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#89 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHPNulVlEPrBqck_7O43sXOTrb-yi0tks5vG47HgaJpZM4aPwlg>
.
|
hmm, I'm not sure how this can include a whole folder of data files. Here's my conundrum: The project structure in this PR looks like this:
If I install with What I'd actually like to happen is that either:
would also exist, or
would exist. Any ideas on how that could happen? |
glob(“dir/*”)
…On Fri, Jan 25, 2019 at 6:34 PM Chris Holdgraf ***@***.***> wrote:
hmm, I'm not sure how this can include a whole *folder* of data files.
Here's my conundrum:
The project structure in this PR looks like this:
./
├── book_template
├── jupyter_book
├── requirements.txt
└── setup.py
If I install with pip, then this goes to
.../site-packages/jupyter_book/<contents-of-jupyter_book-folder>.
What I'd actually like to happen is that either:
.../site-packages/book_template/
would also exist, or
.../site-packages/jupyter_book/jupyter_book
.../site-packages/jupyter_book/book_template
would exist.
Any ideas on how that could happen?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#89 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHPNoD2-r7ZoikPKjpGFipo55DyopW-ks5vG77GgaJpZM4aPwlg>
.
|
so that's basically what I'm doing: then Shouldn't running |
import os.path as op | ||
from glob import glob | ||
|
||
template_files = glob(op.join('jupyter_book', 'book_template', '**', '*'), recursive=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template_files = glob(op.join('jupyter_book', 'book_template', '**', '*'), recursive=True) | |
template_files = glob(op.join('book_template', '**', '*'), recursive=True) |
Following the shablona example, I think that this might need to be a path relative to the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, if that doesn't work:
template_files = glob(op.join('jupyter_book', 'book_template', '**', '*'), recursive=True) | |
template_files = [op.join('book_template', '*'), op.join('book_template', '*', '*')] |
And so on, for as many levels of recursion as you need.
3b7b031
to
0ad9a6e
Compare
ahh I think I figured it out - there was a gotcha in there. |
OK I have a demo of the CLI running on Binder here: https://mybinder.org/v2/gh/choldgraf/jupyter-book/cli?urlpath=terminals/2 that'll open JupyterLab - you should be able to then open a terminal and type
and it'll create a jupyter book in you should then be able to run:
and it'll build the markdown for the book. If anybody wants to give it a shot and give feedback on the API etc, that'd be helpful! (and thanks @arokem for the help on the package_data!) |
7467d89
to
abda155
Compare
I just tried it out and it works great! I was going to suggest removing the The only issue is that I'm unable to serve the book on binder:
|
Woot! thanks for the feedback - the latest push adds a Any other thoughts on the CLI itself? Seems like a reasonable choice to create books / update old books / etc? Edit: hmmm I take that back, it doesn't seem like Binder can build the gems needed because a file isn't there that it expects to be there:
|
I think the interface is great 👍 |
c98b1a2
to
e60eb8c
Compare
I think your suggestion sounds good. If you wanted to keep the prompts, you could set the default for content as "None" or something similar, with a message that if they don't specify a content dir it creates an empty/simple one. But maybe more trouble than it's worth vs. just removing the prompts. Originally I was thinking of an optional flag similar to --demo, like "--blank" or "--empty" |
OK the latest push removes the interactive prompts for book content. If someone just types:
then it'll simply add a bare-bones book w/ just a few pages of content to get you started (and adds this to the notice at the end). If you add content with the @kysolvik wanna give that a shot? seem more intuitive? less? |
Hi Chris, this is looking good! One question about consistency: in the book setup the flags for the path to the toc, config, etc are just |
@lheagy I think that's a great point, will take a pass to standardize these flags |
ok, CLI should now be more consistent. Thanks for all of your advice on this one @arokem @gnestor @kysolvik @yuvipanda and @lheagy - if you have any other thoughts please do share them! Otherwise I'll plan on merging this ~tomorrow after going through the docs once more |
…ly empty minimal repo
ok! I took another pass at docs and updated the TOC part of the CLI, and magically the tests are still passing, and so I am merging this!! Let's goooooo 🎉 |
This is a CLI to generate books, riffing off of #87 here's the help section:
Creating new books:
Building book markdown:
If you don't give a
--content-folder
or--toc
parameter, then it'll ask you to manually input the path to one per @arokem's suggestions.Upgrade the book
This will create a copy of the book with the latest jupyter-book
template, then copy over the new files into your current book, preserving
the files that you've modified on your own.
To do
toc.yml
file if none is given (e.g. should it just be a flat list of pages, or should we try to infer page nesting etc)To demo the CLI
I have a demo of the CLI running on Binder here:
https://mybinder.org/v2/gh/choldgraf/jupyter-book/cli?urlpath=terminals/1
that'll open a terminal - you should then be able to type
and it'll create a jupyter book in
<arbitraryname>
with the "demo" content (which is the content from the website).you should then be able to run:
and it'll build the markdown for the book.
Comments?
What do folks think about this general approach? Thoughts ideas etc would be appreciated! cc also @yuvipanda !