Comments (5)
Yep, it is a nice idea to create books from vignettes. This idea has been on my mind for a couple of years, e.g. https://dl.dropboxusercontent.com/u/15335397/slides/FHCRC-VTN-2013-Yihui-Xie.html#/20 An R package is basically a small well-structured universe.
I think it is possible and easy to come up with a vignette engine to render Rmd vignettes as a book, but we will need some support from base R. For example, R CMD build
should not clean up any output files of the book (currently it does clean up everything except the single html output file).
Or we just do not use vignettes, but put the book in a different directory, e.g. inst/book/
, and build the book during R CMD build
(it is easy to find a spot to trigger the build). The only problem is this is not as discoverable as vignettes in the package, but I think this issue is trivial. We could definitely provide some helper functions that behave like vignette()
to show the book.
from bookdown.
- To be honest, I use
serve_book()
myself when I write a book, so there is no need to click a button. - Not an issue. You can do anything you want with a shell script. It does not matter whether the project is an R package or a book, or where the book directory is.
I don't really see huge benefits of incorporating a book into the vignette system of an R package. I think it is possible, though. One idea is you put the book source files elsewhere (anywhere except the root directory vignettes/
), e.g. a subdirectory of vignettes/
: vignettes/my-book/[index.Rmd|chap1.Rmd|...]
. Then you use a placeholder Rmd vignette vignettes/foo.Rmd
to build the book under vignettes/my-book/
(do this in a code chunk in foo.Rmd
; just call bookdown::render_book()
with appropriate settings). After the book is built, copy the output back to vignettes/
. You will need vignettes/.install_extras
to make sure R does not wipe out the book output: https://cran.rstudio.com/doc/manuals/r-release/R-exts.html#Writing-package-vignettes This is essentially a hack, but I think it is a feasible way to go, if you want to pursue the idea of building a book inside a package.
from bookdown.
interesting idea.
I was thinking the other day that it would be inelegant to have both vignettes (maintained with the package) and some book about an R package.
On the other hand, this dual role could make things more complicated.
from bookdown.
I'm still thinking about this, and I noticed that this very project bookdown
actually is both a book and a package, as @yihui also mentioned in #215
I'd be curious to hear some more guidance and/or experiences with this.
Would you recommend this for other package/book combinations and/or be willing to add this to the bookdown
documentation @yihui ?
I gather the following shortcomings / complications should be borne in mind:
- RStudio
build
will only be able to build one of the two (package or book), though serving viaserve_book()
might be a good way to continuously build the docs, while continuing to build the package via RStudio buttons. - Travis (or other) CI might need a slightly more complicated shell script, though I can't see why it couldn't first build a package, and then render a book. Or could that be an issue?
- ... anything else I missed?
I'm also still wondering whether, say, the (K+Med) book chapters might also be vignettes in and of themselves.
Uh, I don't know, sometimes I make things too complicated for myself, I'd just really appreciate some guidance/experience from @yihui if you have the time for some comment.
from bookdown.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
from bookdown.
Related Issues (20)
- How could I add a link for the "Edit" icon to private Bitbucket repo? HOT 11
- .unlisted and .unnumbered not excluding tagged headers from TOC HOT 5
- [FR] Add support for the YALM setting "language: ui: references_name" to change the title of references section in html output HOT 7
- Image embeded in flextable lost in .docx output HOT 3
- [FR] Typst Support HOT 3
- Equation in book is broken HOT 3
- [FR] Allow to use `$$` for numbering equation in **bookdown**
- R4.3 error if multiple files are passed to `render_book` without an `output_format` specified HOT 2
- crosstalk html widget doesn't display the figure caption HOT 3
- html output error with echo=FALSE option HOT 1
- [FR] Multi language support
- Square brackets around citations in text HOT 2
- Cannot generate pdf via "server" but only html despite I tried probably all suggestions. HOT 4
- Use of 'tab.scap.' for tables? (Non kable() users!) HOT 2
- Hyphenation only works in English HOT 17
- bs4_book - references by chapter not displaying HOT 1
- The manual's recommendation of only previewing the web version is dangerous. HOT 5
- Search in gitbook doesn't work because of empty search_index.json HOT 5
- Check and adapt to new `--number-sections` in Pandoc 3.1.12 HOT 5
- Unnumbered didn't work properly HOT 8
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 bookdown.