Closed HanOostdijk closed 5 years ago
Following up on the coverage test I see that I will have to add to
.\namer\tests\testthat\test-unname_all_chunks.R
the case that the ch_n_p
argument is not NULL
.
:wave: @HanOostdijk, thanks for your PR! It is a generally welcome feature, I'll comment about details.
I'd prefer the name of the argument to be longer and therefore more explicit e.g. chunk_name_prefix
. By the way, could you describe your use case for that?
@HanOostdijk I've pushed minimal changes to your branch and will merge if you agree with my adding you as contributor to DESCRIPTION. I did that via desc::desc_add_author_gh("HanOostdijk")
so hopefully the info is correct.
One last thing actually, could you please add a paragraph about your use case in the vignette and README after "There's also name_chunks
for use on a single R Markdown file; and unname_all_chunks
to unname all chunks of a single R Markdown file which can be useful when cleaning your chunk labels."? Thanks!
The current version of unname_all_chunks removes all chunk labels except
setup
.My proposal is to add an argument
chunk_name_prefix
(chunk name prefix) that when used will indicate which labels will be unnamed by specifying the prefix of these labels.The default value for this argument is
NULL
and in that case the current processing will be done: all labels removed exceptsetup
.For the two cases an example is given in the documentation of the function unname_all_chunks.
Use case: I sometimes refer to existing labels by using the chunk option
ref.label
. For an example ofref.label
see e.g. Chunk Reference/Macro . After usingname_chunks
I have a set with 'own' labels and a set with 'generated' labels. When I later decide that I want to insert new chunks, I would prefer to unname only the 'generated' labels and then applyname_chunks
again. With the suggested change, this can be done by specifying aschunk_name_prefix
'the filename with extension stripped' followed with a '-' (dash) that is used inname_chunks
.Apart from unname_all_chunks I also inserted a second named chunk in example4.Rmd in the example folder.
I am not very familiar with the PR process. Let me know when I made mistakes.
Edited:
ch_n_p
argument renamed tochunk_name_prefix
following suggestion by reviewerstringr
is removed because thestringr
functions are no longer used