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

rd_to_qmd_to_md #53

Closed

Conversation

vincentarelbundock
Copy link
Collaborator

@vincentarelbundock vincentarelbundock commented Oct 29, 2023

This is a PR to get @rempsyc started on the next phase of the project. This PR includes two new functions:

  • rd_to_qmd() converts man pages from the man/ directory to Quarto files.
  • qmd_to_md() converts Quarto files to markdown files.

Examples should be executed and rendered, but I have not tried examplesIf tags, so this should be tested.

Could you take a look at it and see how the outputs compare? If there are no backward changes and the improvements are unambiguous, we could aim to use this as the main mechanism to convert man pages to appropriate markdown in all formats.

I probably won't have time to work on this in the near future, so feel free to fork or push to this branch.

@rempsyc
Copy link
Collaborator

rempsyc commented Oct 29, 2023

Does that mean I can ignore #39?

@vincentarelbundock
Copy link
Collaborator Author

We can break up the Quarto aspects of the project in 3 parts:

  1. Convert Rd files to MD files by going through Quarto
  2. Convert Quarto vignettes to MD files. Currently, all the files in vignettes/ have to be Rmarkdown, but we want to allow users to write their vignettes in Quarto instead. Those won't be able to be be published to CRAN because they don't support Quarto, but we can display them nicely on the package website.
  3. Create a whole website for documentation in the "book" Quarto format (instead of docute or docsify)

The present PR is a (complete?) attempt for the first of those three steps.

@rempsyc
Copy link
Collaborator

rempsyc commented Oct 29, 2023

From the get go, I can say that .rd_to_qmd seems to work properly for datawizard, but .rd_to_qmd errors because it seems like it cannot find the package functions when rendering the example, probably because it renders them in a new environment.

I looked at quarto::quarto_render but did not find an argument for this purpose, so the solution (I think?) could be to load the package within this new environment, e.g., by adding library(datawizard) to every example.

library(quarto)
library(datawizard)
source_file <- "man/winsorize.Rd"
target_dir <- "man"
.rd_to_qmd(source_file, target_dir)
source_file <- "man/winsorize.qmd"
.qmd_to_md(source_file)

processing file: winsorize.qmd
1/3                  
2/3 [unnamed-chunk-1]

Quitting from lines 128-152 [unnamed-chunk-1] (winsorize.qmd)
Error in `winsorize()`:
! could not find function "winsorize"
Backtrace:
 1. graphics::hist(...)
Execution halted
Error in `processx::run(quarto_bin, args, echo = TRUE)`:
! System command 'quarto.exe' failed
---
Exit status: 1
stdout & stderr: <printed>

This is when running .qmd_to_md outside of altdoc since it is not integrated already, but I tried integrating the workflow with lapply calls within the other Reference rendering functions, and I am getting the same result..

@rempsyc
Copy link
Collaborator

rempsyc commented Oct 29, 2023

I think I cannot push changes directly to this PR/branch since you created this PR on a branch from your own fork rather than on etiennebacher/altdoc. It seems I must make a PR to modify your branch... We have permission to create branches on the main repo though so I think that would be better. I think, I will create a new PR with the same code changes. Then it will be easier to collaborate.

@rempsyc rempsyc mentioned this pull request Oct 29, 2023
4 tasks
@vincentarelbundock
Copy link
Collaborator Author

Maybe you can start trying with marginaleffects, since they will be our target anyway.

datawizard examples should always load the library, but it seems they don't...

@rempsyc rempsyc closed this Oct 29, 2023
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.

2 participants