Skip to content

feat: Discover VS Code, Quarto and renv projects#130

Merged
krlmlr merged 10 commits intomainfrom
add-more-criteria
Aug 28, 2025
Merged

feat: Discover VS Code, Quarto and renv projects#130
krlmlr merged 10 commits intomainfrom
add-more-criteria

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 it 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
\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 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.

"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).


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!

\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
@jennybc
Copy link
Member Author

jennybc commented Jul 23, 2025

@krlmlr I think this is ready to go and I'm sort of assuming this will be merged, in terms of stuff I'm doing over in usethis 😅, which I hope to release soon-ish.

It doesn't really require dev rprojroot. But it helps to generate the docs in the presence of my rprojroot PR.

@jennybc
Copy link
Member Author

jennybc commented Aug 27, 2025

I just freshened this PR @krlmlr, in light of the rprojroot release, so I think it's in good shape.

@krlmlr krlmlr changed the title Add criteria: vscode, quarto, renv feat: Discover VS Code, Quarto and renv projects Aug 28, 2025
@krlmlr krlmlr merged commit 3c3012d into main Aug 28, 2025
5 checks passed
@krlmlr krlmlr deleted the add-more-criteria branch August 28, 2025 02:51
@krlmlr
Copy link
Member

krlmlr commented Aug 28, 2025

Thanks!

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