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

Access contents of document outline #153

Open
whtns opened this issue Sep 3, 2019 · 8 comments
Open

Access contents of document outline #153

whtns opened this issue Sep 3, 2019 · 8 comments

Comments

@whtns
Copy link

whtns commented Sep 3, 2019

I'd like to be able to access the document outline visible via Code > Show Document Outline. Is this possible?

@GegznaV
Copy link

GegznaV commented Sep 4, 2019

Are you searching for this?:

rstudioapi::executeCommand("toggleDocumentOutline")

@whtns
Copy link
Author

whtns commented Sep 5, 2019 via email

@kevinushey
Copy link
Contributor

We don't currently expose the contents of the document outline in a way accessible to R. I'd be curious to know a bit more about your use case.

@sfr
Copy link

sfr commented Feb 8, 2021

The case for this might be #8006.

@violetcereza
Copy link

Hi yes this feature would be very helpful for me!

I am trying to write a tool that aggregates my TODO items across my project. Similar to this package but I'd like to add document headers interspersed with to-do items. The package also doesn't support qmd files, and designing text processing across many different languages and comment styles seems fragile and unsustainable.

I am planning on building a text processor with this snippet but it's not that flexible and doesn't work for the "functions and sections" outlines in R scripts.

@olivroy
Copy link
Contributor

olivroy commented May 16, 2024

@dapperjapper, the reuseme package (a usethis-inspired package that I could have named usethisExtra) https://olivroy.github.io/reuseme/ does just that.

You may be interested in reuseme::proj_outline()

Disclaimers: it is not that widely tested in the nature and is built on regular expressions, rather than proper file parsing. It has pretty much only been tested with RStudio and within RStudio projects.

# Installation
install.packages('reuseme', repos = c('https://olivroy.r-universe.dev', 'https://cloud.r-project.org'))
library(reuseme)
# all elements
proj_outline()
# only todo
proj_outline("TODO") # can be any regex.

If you give it a try and have suggestions, feel free to open an issue or comment on olivroy/reuseme#28. I am currently actively developing this feature in my package at the moment, so now is a good time.

Here is a screenshot of how it looks in my console
Note that all the underlined text are clickable links that take you to the location.
image

It works better with the latest version of RStudio 2024.04.1, but it probably works okay with some recent ones as well.

@violetcereza
Copy link

@olivroy Amazing -- thank you so much!

@whtns
Copy link
Author

whtns commented May 17, 2024

@olivroy looks cool!

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

No branches or pull requests

6 participants