Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented May 11, 2020

This fixes #885 and follows a series of features addition for source_files (#561, #601) in the past.

There was still an issue when rmd_files is provided with rmd_subdir due to the following behavior:
when rmd_subdir was provided, all the files from root dir and subdirs were selected. rmd_files was not able to filter out the desired root files.

This PR will identify subdir files apart from root files if rmd_subdir is provided, then if rmd_files is provided also, it will concatenate rmd_files with rmd_subdir content only, discarding any other root files content.

This PR also add tests so that all the desired behavior are checked:

  • by default, only root files are selected apart from ignored files (starting with _)
  • rmd_files allows to select the root files and change default behavior
  • rmd_subdir allows to add some subdirs content - by default root files
  • rmd_subdir = TRUE will get all the subdirs Rmd content.
  • if rmd_files is not provided, the files starting with an underscore in subdirectories will also be ignored.
  • rmd_files allows to select the root files selected, in addition to rmd_subdir, adding those with the subdir content.

However, in this last case, there is one behavior which is currently happening and not sure it is desired: if rmd_files AND rmd_subdir are provided, the files starting with _ inside sub directories will not be ignored anymore. Is this the desired behavior?

I wonder if

  • _*.Rmd files should be always ignored in bookdown. Would be a change in default, but you just need to remove the _ and use rmd_files if you want to include it in some cases
  • if it should be ignored by default in subdir content in all case.

What do you think ?

@cderv cderv requested a review from yihui May 11, 2020 06:56
Copy link
Contributor

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if rmd_files AND rmd_subdir are provided, the files starting with _ inside sub directories will not be ignored anymore

I think we should always ignore files starting with _, otherwise the logic sounds too complicated to explain to users and also complicates the implementation. Thank you!

@yihui yihui merged commit 00a4a04 into rstudio:master May 14, 2020
yihui added a commit that referenced this pull request May 14, 2020
@cderv cderv deleted the fix-885 branch May 14, 2020 20:24
@rickhelmus
Copy link

rickhelmus commented May 28, 2020

I think we should always ignore files starting with _, otherwise the logic sounds too complicated to explain to users and also complicates the implementation. Thank you!

Hello,

This unfortunately breaks the recommendation of pkgdown to use underscores to cooperate with bookdown (see build_articles()). Is there still a way to include files with initial underscores?

Thanks,
Rick

@yihui
Copy link
Contributor

yihui commented May 28, 2020

@rickhelmus I don't see how it breaks the recommendation of pkgdown. The help page says:

build_articles() renders each R Markdown file underneath vignettes/ and saves it to articles/. There are two exceptions:

  • Files that start with _ (e.g., _index.Rmd) are ignored, enabling the use of child documents in bookdown

  • Files in vignettes/tutorials are handled by build_tutorials()

So pkgdown also ignores files that start with _, which is consistent with bookdown. If you do want to use files that start with _, you can use them as child documents of other files that do not start with _.

@rickhelmus
Copy link

Hi yihui,

Thanks for your answer. I wasn't being really clear, sorry. I am actually already using one 'master' Rmd that includes several child documents. The problem is that I want to exclude this master document from pkgdown. Anyway, this may be more a feature request for pkgdown so I created a bug there.

Thanks,
Rick

@yihui
Copy link
Contributor

yihui commented May 30, 2020

@rickhelmus Okay, now I see. Sorry about the trouble! Let me think more about it.

@cderv
Copy link
Collaborator Author

cderv commented May 30, 2020

Hi @rickhelmus ,

Just chiming in as I am trying to understand the interaction between pkgdown and bookdown in your usage.

The problem is that I want to exclude this master document from pkgdown

As you are using pkgdown, I understand your working on a package. Then, I understand that you have a bookdown project inside your package that you store in the vignette folder but you don't want to get it rendered as article in your package doc website. Correct ?
Or is is not a book project and are you just using one of the single document format (bookdown::html_document2 ?) for you master.Rmd ?

If you can provide a complete use case (maybe in a new issue) I am willing to dig into it to see what could be done on pkgdown or/and bookdown about this usage.

However, @yihui seems to have a more clearer picture than mine though, so maybe this won't be necessary 😄

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build w/ rmd_files: ["index.Rmd"]<cr> rmd_subdir: "chapters" includes ./_Notes.Rmd

3 participants