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

[R] improve docstrings for "xgb.Booster.R" #9906

Merged
merged 5 commits into from
Dec 21, 2023
Merged

Conversation

mayer79
Copy link
Contributor

@mayer79 mayer79 commented Dec 19, 2023

This PR introduces Markdown docstrings. It is the first step towards #9875.

  1. To keep the PR not overly large, the changes are focussing on the file "xgb.Booster.R" which mainly contains the predict() function.

  2. Besides switching to Markdown, I am also cleaning small inconsistencies in the docstrings, change some wordings, and format some examples a bit neater.

  3. Quite unrelated, the third commit removes a warning in an example related to an inexisting parameter silent.

I am aware that such reviews cost time. At least, I am not changing anything in the functions.

@trivialfis
Copy link
Member

cc @david-cortes .

@trivialfis
Copy link
Member

Hi @mayer79 , thank you for the work on using markdown syntax, could you please take a look into the CI failures?

@mayer79
Copy link
Contributor Author

mayer79 commented Dec 20, 2023

The problem came from existing square brackets in the documentation. They are parsed differently under Markdown. This should now be fixed.

Here is an example how the help will show to users:

Old

image

New

image

Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

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

Looks good to me, would be great if @david-cortes could help take a look as well.

@trivialfis
Copy link
Member

Unrelated note, would be interesting if roxygen can output markdown without converting it into rd, we can plug the document into sphinx then XGBoost's document site can display R API just like the Python API.

@david-cortes
Copy link
Contributor

LGTM.

While you're at it, perhaps you could also look into misrendered things like this:
image

I think it was there before, but could also benefit from correct tags and formatting.

@david-cortes
Copy link
Contributor

Unrelated note, would be interesting if roxygen can output markdown without converting it into rd, we can plug the document into sphinx then XGBoost's document site can display R API just like the Python API.

I don't know if that's possible, but looks like the R docs can otherwise be rendered as a similar-looking HTML (don't know how though). For example, lightgbm has a page for R docs which is auto-generated from the roxygen code: https://lightgbm.readthedocs.io/en/latest/R/reference/

@mayer79
Copy link
Contributor Author

mayer79 commented Dec 20, 2023

While you're at it, perhaps you could also look into misrendered things like this:

I think it was there before, but could also benefit from correct tags and formatting.

In what .rd file is it? The aim of this and upcoming PRs is definitively to also fix things liket his.

@david-cortes
Copy link
Contributor

While you're at it, perhaps you could also look into misrendered things like this:
I think it was there before, but could also benefit from correct tags and formatting.

In what .rd file is it? The aim of this and upcoming PRs is definitively to also fix things liket his.

That particular screenshot was from xgb.ggplot.shap.summary.

@trivialfis
Copy link
Member

I don't know if that's possible, but looks like the R docs can otherwise be rendered as a similar-looking HTML (don't know how though).

We can convert Rmd files into md files, then consume it using sphinx using knit, just wondering if that's possible with Rd files as well. Not important at this point, just something nice to have in the future. Apologies for the distraction.

@mayer79
Copy link
Contributor Author

mayer79 commented Dec 20, 2023

@trivialfis

There is a git pages workflow that uses the {pkgdown} package to generate HTML files. Here is an example such a help page of such a function: https://modeloriented.github.io/shapviz/reference/sv_dependence.html

The translation happens via pkgdown::rd2html() . This first parses the rd tags and then translates each of them to html.

@mayer79
Copy link
Contributor Author

mayer79 commented Dec 20, 2023

@david-cortes : I will go over this help file in the next PR. Hope to fix the majority of such things as well.

@mayer79 mayer79 changed the title [R] improve docstrings (1) for "xgb.Booster.R" [R] improve docstrings for "xgb.Booster.R" Dec 20, 2023
@trivialfis
Copy link
Member

Thank you for sharing, I will look into it.

@trivialfis trivialfis merged commit b807f3e into dmlc:master Dec 21, 2023
24 of 28 checks passed
@mayer79 mayer79 mentioned this pull request Aug 26, 2024
25 tasks
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