-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add RStudio addin for interactively creating a new post from a template #12
Conversation
Hi Michael, Thank you so much for your interest and enthusiasm for distilltools, and this big contribution to it 😄 I have a really busy week ahead so it might be a few days before I have a chance to review this PR properly, but I wanted to reply ASAP to say that I'd seen it, that I really appreciate it, and that I'll get back to you properly as soon as I can. |
…ltools.templates.path = <...>)
Hi Ella, You're welcome. I hope these are helpful 😄 Thanks for letting me know. I also added a new commit that allows users to set the template directory path |
Hi Michael, Yes, this is definitely helpful, and, as you've since noticed, something that other users have requested too 😄 I've had a first look at some of this and overall really like what you've done. I have a few comments:
Anyway, that's just some thoughts on what I've had a chance to look at so far. Overall, I think it's really good and you've obviously done lots of work on this and I definitely think we can work out the above to get this PR incorporated into the package. I look forward to hearing your thoughts. |
…hen users have no local templates
Thanks Ella! The feedback was very helpful and I agree with most of it. I've pushed some new commits that address the feedback:
|
…nction, not just in testing
Hi Michael, Thanks for making those changes 😄 I'm glad we're on the same page about things! Again, it may be a few days before I have a chance to review in full, but I'll be sure to get back to you as soon as I do. In the meantime, one small additional commit, please - can you bump the version number to 0.0.0.9002 in DESCRIPTION? Thanks! |
Done. Talk soon! 😄 |
Hi Michael, Thanks for these changes 😄 and all your work on this. I think this is getting really close and I'm excited about launching this feature soon! I think that the default path for templates could be even simpler. Can we just have a folder in the root directory called Also, I double-checked the build, and saw 0 errors, 0 warnings and 0 notes, so very big thumbs up on that 👍 Hopefully we can get this wrapped up in the next week or so. I should next have a chance to review changes at some point over the weekend. |
Hi Ella, You’re welcome! Looking forward to launching it! 😄 I probably won’t have time to make any changes until closer to the end of the week. The current implementation actually lets you name the If we were to change the current function to look directly in Right now the function uses the subdirectory name to name the path. This keeps the code fairly simple, since every subdirectory in The workaround for this I can think of is to check if multiple templates in subdirectories share the same name, and if so then add the subdirectory name onto the shared name in some way (or replace the shared name with the shallowest subdirectory name). But I feel that this will overcomplicate the code, which also means overcomplicating the documentation for So I would prefer to keep the function as is if you have no objections (unless you have alternative suggestions on how to implement your suggested change without restricting users or overcomplicating things in the ways mentioned above). I think having a, e.g., Let me know what you think and we can figure out where to go from here! |
Hi Michael, Thank you very much for your comments and thoughts above. It's really helpful to have some more of your explanation for how the function works and your thinking behind it. Sorry, I missed the comment in the documentation about the naming the .Rmd files - you're right, it's there and it's clear! Also, I wanted to thank you for engaging in this discussion with me about what essentially amounts to a question of simplicity vs flexibility. It's a delicate trade-off and it's not obvious that there are right or wrong answers here. It's going to be an issue not just in this function but for the package as a whole, still in its very early stages of development, so having someone to bat these ideas around with is really helpful, and allows me to see how the package is used by someone other than myself. I think my comments below might get quite long, so please bear with me 😄 I suppose when it comes to naming templates, I can't see who someone would want, say, But the issue I have with that file structure, i.e. using subdirectories and taking template names from the folder name rather than the .Rmd file, is that it sets up an inconsistency between However, in Having individual templates as subdirectories of a
I think that the way that .Rmd templates are created in regular R packages is throwing up a bit of a red herring. In that case, it is possible, and often necessary, to bundle supporting files with the skeleton.Rmd file, because packages are designed to be shared with others. So, for example, in a PhD package I wrote that I share with my supervisors, I have an .Rmd template for writing a report that gets bundled with a .bib, a .csl and a .css file. However, I'd argue that in the context of distilltools, we'd want to explicitly discourage that. It's never necessary because For example, I used a custom syntax highlighting theme on my website, and I have that file in my root directory, then in my
I'd argue that that is far preferable to bundling For all those reasons, it was a deliberate decision to only have So, just as somewhere in the root directory of a distill site, you might have a directory called You say that you don't want to restrict users or over-complicate the function. What I'm going to propose I think does neither (well, maybe the former, a smidge), and in fact would considerably simplify the function. I suggest removing the functionality to support subdirectories because, as I hope I have convinced, they are not only unnecessary but potentially confusing and inconsistent with how That might restrict users in that it's very opinionated about file structure, but it doesn't restrict them at all in terms of functionality. In fact, I prefer to think of it as helpfully containing them rather than restricting them! You would lose, I'm afraid, the ability to have generic names for the template .Rmd files, but (at least in my opinion) that's a small price to pay for this simpler approach (but, that's easy for me to say, because I already admitted I couldn't see why you'd want that). And, I do appreciate that it might be galling that I'm suggesting that you remove functionality that you've clearly put a great deal of thought and effort into supporting. Anyway, thank you for bearing with me through all that! I hope it makes sense. That's my view on things as they stand, but I may well be missing something. You say that supporting subdirectories is an important feature that you want to keep in. Why? What use case do you see for subdirectories (other than allowing generic names for names for the template .Rmd files)? Why do you think that allowing generic names is important? I am genuinely curious and worried that I'm missing something important. At the moment, I think it's more important for I really look forward to hearing your thoughts on the above. I know it's a lot, so no worries if you want to take some time to think about it! |
Done, done, and done 😎 We're definitely almost there! And likewise, it's been a pleasure working with you too. One note: Doing And two other small things:
|
Hi Michael, I think you may need to remove the back-ticks from around the square brackets, or put them inside it. See the 'Links' section of this vignette. I think you may also need to run On your other two points:
|
You do need to run I added One (last?) thing! What do you think about renaming edit (knew there was something else!): It would probably be good to mention the RStudio addin in |
Thanks Michael, My comments below got a bit long (again!) so I've tried to organise them. I think it's a lot of text for fairly few tweaks, though! Missing .Rd and doc files I know you say that you've fixed the issue of links not working in
I don't actually mind There are a few other names that could work. What about Despite the number of words I've now dedicated to it, I really don't feel that strongly about this function name. I see it mostly as a helper function for the addin and something that it's unlikely that users are going to call themselves (except maybe if they're debugging). Happy to go with your preference (including changes to
changes to
updates to README Yes, also, to updating the README to mention the addin and
change to addin name? One other idea I've been ruminating on is changing the name of the addin in the dropdown list to "Create post (including from template)". That's slightly less consistent with the |
…eing run from a tempdir
I figured there would be more changes coming so I didn't commit docs and pkgdown changes last time. I did this time so it's easier for you to look though 😄 available_templates nameI've left it as is for now. I also don't feel too strongly about it since I'm good keeping it as is. I also thought changes to available_templates() documentationDone. changes to create_post_from_template() documentationFixes made. Let me know what you think about the changes I made. I edited the existing documentation to make it less verbose (but hopefully still just as clear), and tried to shorten the paragraph you suggested as well as have it reflect what was already written in updates to READMEDone. I also fixed the header levels throughout the README, and added subheadings under functionality to group the headings. The headings I chose align with the sentence at the start of the README
change to addin name?I don't feel too strongly here as long as the name is clear about what the template does. Some thoughts:
|
Thanks Michael 😄
|
No problem! Final tweaks made--I think we're good to go! 😄 |
Done! 🎉 🎉 🎉 Thank you SO MUCH, Michael, for absolutely everything on this 👏 👏 👏 . From you initial enthusiasm for {distilltools} to initiating the PR with a pretty much fully-functioning addin, to engaging with me in numerous debates about fine-tuning it, to making what probably seemed like never-ending tweaks at my request, to tidying up the docs, you've been an absolute pleasure to work with on this. I hope we have opportunities to collaborate again in the future 😄. If you have any further ideas for additional {distilltools} functionality (especially as you continue to develop TidyTales), do let me know! |
Woohoo! 🎉🎉🎉 You’re very welcome! Thank you for the kind comments 😄 This was my first contribution to another R package and you made it a great experience. It was a pleasure working with you too! So likewise, I hope we can do so again! I was thinking a wrapper function for Miles McBain’s HTML script to add Utterances comments to distill articles might be a nice addition. Utterances allows themes and some other customizations, wrapping the creation of the script file into a function would make the availability of those customizations more explicit (and might also just make distill users more aware they can even use Utterances instead of Disqus). |
I hadn't realised it was your first package contribution. What an absolutely stellar way to start! No doubt not your last, at least hopefully not for distilltools, and I'm sure you'll continue to make your mark elsewhere across the R ecosystem. I really like your idea for the utterances function 😄 I have utterances enabled on my blog but hadn't realised it was customisable (at least not until I dug into your TidyTales templates and css 😎!) Have you seen this blogpost on enabling Utterances on distill blogs? I think it's been pretty widely shared and most distill blogs I've seen that have initiated comments have used Utterances rather than Disqus, but I think the function you're proposing would certainly be a great way to keep making a point for the preferability of the former over the latter! It would also be a different kind of function for distilltools and so a nice test case for thinking about how it will best work from a user experience point of view, e.g. where the script gets saved, do we need to write any css anywhere and if so what kind of assumptions might we make about what the user already has (e.g. whether they've run I might be a little slower to respond to things for a while - lots of work and family commitments at the moment. But I'm certainly happy to take a look at whatever you have in mind as and when I get the chance and I'm sure we'll get there eventually! |
Thanks, I appreciate it! 😄 I believe that's the blog I followed when searching how to add Utterances! So you're probably right it's been widely shared and is easy to find. But convenience is always nice! I'll open an issue where we can continue our conversation. No worries about slower responses, I need to focus on work for my Master's thesis right now so I'll be a bit busier too. |
Cool package! I'm in the midst of creating a distill blog and really like the vision of this. I wanted to contribute with something users will likely find helpful:
I've created an RStudio addin that allows users to create a new post from a template interactively (similar to the new post addin for {blogdown}), which makes up the bulk of the changes in this pull request. It's essentially just a wrapper for
create_post_from_template()
.There are also a few other additions:
A new exported function,
available_templates()
, which lists a new default template located indistilltools/inst/rmarkdown/templates/default/skeleton/skeleton.Rmd
, as well as any templates located in the following path in a user's website projectinst/rmarkdown/templates/template_name/skeleton/skeleton.Rmd
(edit: or a user defined path). This was mainly made as a helper for the addin, and it makes some assumptions about how a user structures the path to their templates. I chose this path structure since it is in line with how you add R Markdown templates to R packages.Testing using {testthat} for
available_templates()
andcreate_post_from_template()
. Although the addin itself cannot be tested with testthat, these provide the necessary coverage. The interactive part has to be checked manually (I did this with my own distill site and it seems to work without error, but you might want to check too in case I missed anything).I added myself as a contributor to the
DESCRIPTION
.