Skip to content

Add criteria: vscode, quarto, renv #130

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add criteria: vscode, quarto, renv #130

wants to merge 7 commits into from

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Jul 15, 2025

Closes #128
Closes #80

@jennybc
Copy link
Member Author

jennybc commented Jul 15, 2025

I was looking around to see what else I might need to update. It doesn't seem like here really advertises the criteria is uses for finding the project directory. And empirically it seems like a lot of people think that only an .Rproj file "works". How would you feel about another PR for docs? Do you have an opinion about where to have a bullet list of the project root criteria used by here?

@krlmlr
Copy link
Member

krlmlr commented Jul 15, 2025

Thanks. I wonder if rprojroot should really be a standalone these days.

You gave feedback to the documentation of this package some time ago, I never took action. It might be time to evaluate the use of i_am() in the wild and adapt the documentation around the intended use cases. The current focus of the "Get Started" vignette on i_am() is confusing, perhaps this really should be another vignette, and a true "Get Started" meets users at all levels where they are.

@jennybc jennybc mentioned this pull request Jul 15, 2025
@jennybc
Copy link
Member Author

jennybc commented Jul 15, 2025

I opened a new issue for the documentation ideas (#132), which is related, but I don't think we need to wait on that.

I've manually tested that all 3 of the new criteria seem to be working.

man/here.Rd Outdated
@@ -49,12 +49,15 @@ until a directory with at least one of the following conditions is found:
\itemize{
\item contains a file \code{.here}
\item contains a file matching \verb{[.]Rproj$} with contents matching \verb{^Version: } in the first line
\item contains a directory \code{.vscode}
\item contains a file \verb{_quarto.yml}
\item contains a file \code{renv.lock} with contents matching "\code{Packages}:\s*\{`
Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently more escaping is needed here. But it's not easily within the control of this PR 🤔

* checking DESCRIPTION meta-information ...Warning: /home/runner/work/here/here/check/here.Rcheck/00_pkg_src/here/man/here.Rd:54: unknown macro '\s'

man/here.Rd Outdated
\item contains a file \code{DESCRIPTION} with contents matching \verb{^Package: }
\item contains a file \code{remake.yml}
\item contains a file \code{.projectile}
\item contains a directory \code{.git}
\item contains a file \code{.git} with contents matching \verb{^gitdir: }
\item contains a directory \code{.svn}
\item contains a directory `.svn"
Copy link
Member Author

Choose a reason for hiding this comment

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

Also weird. Why is this not treated the same as .git? 🤔

@jennybc
Copy link
Member Author

jennybc commented Jul 15, 2025

I fixed the .Rd file with my bare hands, but that's obviously not really a solution.

@jennybc
Copy link
Member Author

jennybc commented Jul 15, 2025

OK now I see where these docs are being produced, so presumably I can fix this. I'll give it a whirl.

@jennybc
Copy link
Member Author

jennybc commented Jul 15, 2025

I went in a circles with regex fixups for a long time. The fundamental problem is having double quotes nested inside of double quotes. This comes up because the description of the is_renv_proj criterion surfaces a regex that bumps up against this.

Eventually I threw in the towel and designed the problem away in rprojroot. So now the docs here depend on dev rprojroot (well, a branch of dev rprojroot at this very moment). First I want to prove that this works. Then we can paper over the dev dependency thing to get here into a CRAN-releasable state.

@@ -9,7 +9,7 @@ format_root_section <- function() {
"starting with the current working directory during package load time,",
"the directory hierarchy is walked upwards ",
"until a directory with at least one of the following conditions is found:",
gsub('"([^"]+)"', "`\\1`", format_root_criteria_items()),
format_root_criteria_items(),
Copy link
Member Author

Choose a reason for hiding this comment

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

I just found this easier to reason about by relocating the gsub() below. Now we do that while each criterion's description is still its own element. This also limits the damage an undesirable regex substitution can do, i.e. limits it to a single item versus communicating across the whole string (that was actually what caused the .svn weirdness before).

@@ -21,6 +21,7 @@ format_root_section <- function() {

format_root_criteria_items <- function(indent = 0) {
format <- format(.root_env$root$crit)[-1L]
format <- gsub("'([^']+)'", "`\\1`", format)
Copy link
Member Author

Choose a reason for hiding this comment

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

New location for this fixup and now looking for single-quoted strings instead of double-quoted.

- contains a file matching `[.]Rproj$` with contents matching `^Version: ` in the first line
- contains a directory `.vscode`
- contains a file `_quarto.yml`
- contains a file `renv.lock` with contents matching `"Packages":\s*\{`
Copy link
Member Author

Choose a reason for hiding this comment

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

This one is the really difficult one!

@@ -49,6 +49,9 @@ until a directory with at least one of the following conditions is found:
\itemize{
\item contains a file \code{.here}
\item contains a file matching \verb{[.]Rproj$} with contents matching \verb{^Version: } in the first line
\item contains a directory \code{.vscode}
\item contains a file \verb{_quarto.yml}
\item contains a file \code{renv.lock} with contents matching \verb{"Packages":\\s*\\\{}
Copy link
Member Author

Choose a reason for hiding this comment

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

TRICKY

@jennybc jennybc requested a review from krlmlr July 17, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand default root criteria: maybe quarto? renv? vscode/positron?
2 participants