Skip to content
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

Recommended way to serve the site? #543

Closed
apreshill opened this issue Dec 23, 2020 · 7 comments
Closed

Recommended way to serve the site? #543

apreshill opened this issue Dec 23, 2020 · 7 comments
Labels
bug an unexpected problem or unintended behavior documentation

Comments

@apreshill
Copy link
Contributor

I typically use the Add-in to serve the site, and I just noticed that serve_site() appears to be an exported function.

Yet, when I use the Add-in, this prints to my console:

blogdown:::serve_site()

But then sometimes when I'm editing a blog post, this prints to my console:

blogdown:::preview_site()

Reading the actual function definition here, I see why they are different. But I was confused. I think we want to encourage serve_site() to start? If so, I cannot see where to change where those ::: print to the console.

@cderv
Copy link
Collaborator

cderv commented Dec 23, 2020

if so, I cannot see where to change where those ::: print to the console.

I think this is a RStudio IDE thing. The addin function is defined here:

Name: Serve Site
Description: Run blogdown::serve_site() to live preview a website locally.
Binding: serve_site
Interactive: true

and as you see, we just give the function name.

I think RStudio IDE assumes this function to run addin may not be exported so it uses ::: to avoid errors. 🤔

@yihui
Copy link
Member

yihui commented Dec 23, 2020

The answer is you only call serve_site().

preview_site() is an internal helper function that you never need to call by yourself. I've tried to hide this call in 59dd8d1. I don't know why it still shows up. I'll investigate more. Update: it seems to be a bug of rstudioapi: https://github.com/rstudio/rstudioapi/issues/213

@apreshill
Copy link
Contributor Author

apreshill commented Dec 23, 2020

Ah gotcha, thank you so much- that helps! I'm working on learning resources and wanted to make sure I understood. Feel free to close :)

@cderv do you think the ::: is worth filing an issue for on the IDE? It is confusing here as folks may assume (like I did) that it was an unexported function.

@yihui
Copy link
Member

yihui commented Dec 23, 2020

We can close this issue after rstudio/rstudioapi#213 is fixed.

I think ::: was used because that's the safe way to go (albeit confusing sometimes). For an add-in, the IDE cannot assume the corresponding function is exported from a package. No matter if it is exported or not, ::: works, but if it is not exported, :: won't work. The IDE should probably try a little harder to check if the function is exported or not, and decide whether to use :: or ::: accordingly.

@cderv
Copy link
Collaborator

cderv commented Dec 23, 2020

The IDE should probably try a little harder to check if the function is exported or not, and decide whether to use :: or ::: accordingly.

Yes I think so. I'll open an issue in the IDE about that.

@yihui
Copy link
Member

yihui commented Jan 20, 2021

Instead of waiting for the RStudio bug to be fixed, I just figured out another way to fix this problem. You should no longer see preview_site() in the console.

@cderv
Copy link
Collaborator

cderv commented Jan 20, 2021

Clever solution! That is awesome! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior documentation
Projects
None yet
Development

No branches or pull requests

3 participants