Skip to content

Reorganize shinychat into a monorepo #56

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

Merged
merged 36 commits into from
May 30, 2025
Merged

Reorganize shinychat into a monorepo #56

merged 36 commits into from
May 30, 2025

Conversation

gadenbuie
Copy link
Collaborator

@gadenbuie gadenbuie commented May 22, 2025

Collecting the web assets, R & Python packages, and docs into a single repo

The scope of this PR is to bring everything together in one place. That encompasses:

  • Moving the R package into pkg-r/
  • Moving JS code from py-shiny into js/
  • Moving relevant chat code from py-shiny into a standalone package in pkg-py/
    • shiny.ui.Chatshinychat.Chat
    • shiny.ui.chat_ui()shinychat.chat_ui()
    • shiny.express.ui.Chatshinychat.express.Chat
    • shiny.playwright.controller.Chatshinychat.playwright.ChatController
  • Setting up documentation
    • We build separate sites for the R and Python packages
    • R: builds into docs/r with pkgdown
    • Python: builds into docs/py with quartodoc
    • docs/index.html is a static splash page for shinychat that directs people to the right docs page.
  • Setting up CI

In follow-up PRs we'll work on paring down features of shinychat for Python.

TODO

  • Move R package and update R package CI workflows
  • Move chat js/css assets
  • Create Python shinychat package
  • Create new documetnation page that combines R and Python docs
  • Add JS CI workflows
  • Add Python CI workflows
  • Add combined docs workflows

@gadenbuie gadenbuie marked this pull request as ready for review May 29, 2025 20:16
@gadenbuie gadenbuie requested review from schloerke and cpsievert May 30, 2025 12:48
```r
links <- c(
  "https://posit-dev.github.io/shinychat/authors.html",
  "https://posit-dev.github.io/shinychat/LICENSE-text.html",
  "https://posit-dev.github.io/shinychat/LICENSE.html",
  "https://posit-dev.github.io/shinychat/news/index.html",
  "https://posit-dev.github.io/shinychat/reference/chat_append.html",
  "https://posit-dev.github.io/shinychat/reference/chat_ui.html",
  "https://posit-dev.github.io/shinychat/reference/index.html"
)

links <- sub("https://posit-dev.github.io/shinychat/", "", links)

template <- r"---(
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Redirect</title>
  <script type="text/javascript">
    var redirects = {"":"{{redirect}}"};
    var hash = window.location.hash.startsWith('#') ? window.location.hash.slice(1) : window.location.hash;
    var redirect = redirects[hash] || redirects[""] || "/";
    window.document.title = 'Redirect to  ' +  redirect;
    window.location.replace(redirect);
  </script>
</head>
<body>
</body>
</html>
)---"

dirs <- fs::path_dir(links)
dirs <- unique(dirs[dirs != "."])
dirs <- fs::path("docs", dirs)
fs::dir_create(dirs)

htmls <- glue::glue(
  template,
  redirect = file.path("r", links),
  .open = "{{",
  .close = "}}"
)

purrr::walk2(links, htmls, function(from, html) {
  writeLines(html, fs::path("docs", from))
})
```
@gadenbuie gadenbuie merged commit c26c769 into main May 30, 2025
12 checks passed
@gadenbuie gadenbuie deleted the monorepo branch May 30, 2025 15:23
Copy link
Contributor

@schloerke schloerke left a comment

Choose a reason for hiding this comment

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

Sorry for the delayed comments...

"jsx",
"tsx"
],
"quarto.path": "~/.local/share/qvm/versions/v1.7.31/bin/quarto",
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels off

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah this is tricky because qvm is the best thing around but also isn't being developed or maintained.

The idea here is that the Quarto version used in the project is controlled with the QUARTO_VERSION string in the Makefile. To update the Quarto version, you change that string and call make install-quarto, which uses qvm to install the desired version of Quarto and updates the GitHub Actions files AND the VS Code settings so that everyone uses the same version of Quarto.

Unfortunately, qvm doesn't give you a way to control where the quarto binary is installed, or we'd use a local folder. I also don't really want to go write code to download and install quarto since that's basically covered by qvm, so we're kind of stuck here.

It also means that in CI, we install quarto but can't use make docs and have to rely on quarto render ..., which is annoying but not the worst thing ever.

schloerke added a commit that referenced this pull request Jun 2, 2025
* main:
  chore(r): Fix readme logo
  chore: Update new R package link
  chore: add recommended extensions
  chore: fix logo
  chore: Add a README
  chore: remove unused scripts
  ci(quartodoc): Builds API docs in CI
  docs: metadata on index/404 pages
  docs: Add custom 404 page
  docs: Remove redirects
  docs: Fixup redirects
  ci(pkgdown): Run when `pkgdown.yaml` changes
  ci(docs): Need `contents: write` permissions
  ci(quartodoc): Needs read permissions
  ci(quartodoc): Use `quarto` binary to render quarto in CI
  ci(verify-js-built): Only check if JS files change
  ci(quartodoc): Just install all extras here too
  Reorganize `shinychat` into a monorepo (#56)
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.

3 participants