Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellga committed Mar 23, 2024
1 parent 060542d commit 550b9e5
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 9 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
# we specify bash to get pipefail; it guards against the `curl` command
# failing. otherwise `sh` won't catch that `curl` returned non-0
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.9.0/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
# sure would be cool if github gave us proper conditionals...
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
# functionality based on whether this is a pull_request, and whether it's from a fork.
Expand Down Expand Up @@ -161,7 +161,8 @@ jobs:
with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.9.0/cargo-dist-installer.sh | sh"
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
- name: Fetch local artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -206,7 +207,7 @@ jobs:
with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.9.0/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
# Fetch artifacts from scratch-storage
- name: Fetch artifacts
uses: actions/download-artifact@v4
Expand Down
17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@ lto = "thin"
# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.9.0"
cargo-dist-version = "0.12.0"
# CI backends to support
ci = ["github"]
# The installers to generate for each app
installers = []
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
targets = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
]
# Publish jobs to run in CI
pr-run-mode = "plan"

allow-dirty = ["ci"]

# Use custom runner for Arm64 build
[workspace.metadata.dist.github-custom-runners]
aarch64-unknown-linux-gnu = "buildjet-2vcpu-ubuntu-2204-arm"

85 changes: 83 additions & 2 deletions _docs/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,87 @@
title: "rdocs"
---

This is a Quarto website.
## rdocs: Simple Quarto documentation for R packages

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.
Allows to create quarto markdown documentation (.qmd) from `///` and `###` tokens in text files. Documentation can be created, for example, from `.R`, `.rs` and
`.cpp` files. \
The package will search for these tokens in the files and generate a quarto website.

This library's [documentation](https://daniellga.github.io/rdocs/) was created using rdocs.

## Instalation

Install [Quarto](https://quarto.org/) and add it to PATH.

Install the package from github:
```r
remotes::install_github("daniellga/rdocs", subdir = "rdocs")
```

## Usage

An example is showed below, where 2 distinct functions will be documented on the same section, named HFft.
It generates a quarto website from lines starting with `###` or `///` that are right above function declarations. \
The website folder is created in the current working directory. \
The first line of the block is important, since the name of the variable will be used to group functions into the
same one-worded section. This is useful, for example, when working using an OOP approach. For now, to avoid any
bugs, it is important that all grouped functions are on the same file. \
The user is free to create its headings, line breaks and make use of all other markdown utilities. \
All R code identified by r code markdown blocks will be evaluated in a separate R session. If you don't want a certain part of the
code to be run, it will be needed to comment it or avoid the code block representation. If you don't want to evaluate
the code at all, use `run_examples = FALSE`, which is the default.

`testscript.rs`
```r
/// HFft
/// ## fft
///
/// `fft() -> HArray` \
///
/// Computes the fast fourier transform of the `HArray`. \
///
/// #### Returns
///
/// An `HArray`. \
///
/// #### Examples
///
/// ```r
/// arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4))
/// dtype = HDataType$float32
/// HArray$new_from_values(arr, dtype)
/// HFft$fft(harray)
/// ```
///
fn fft(harray: &HArray) -> HArray {
HArray(harray.0.fft())
}

/// HFft
/// ## fft_mut
///
/// `fft_mut()` \
///
/// Computes the fast fourier transform of the `HArray`. \
/// The operation is done in-place. \

/// #### Examples
///
/// ```r
/// arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4))
/// dtype = HDataType$float32
/// HArray$new_from_values(arr, dtype)
/// HFft$fft_mut(harray)
/// ```
///
fn fft_mut(harray: &mut HArray) {
let inner_mut = harray.get_inner_mut();
inner_mut.fft_mut()
}
```

```r
rdocs::generate_docs("./testscript.R")
```

The website will be generated on the current working directory.
2 changes: 1 addition & 1 deletion rdocs/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Title: Create Quarto documentation for R files from comments
Version: 0.1.20
Authors@R:
person("Daniel", "Gurgel", , "[email protected]", role = c("aut", "cre"))
Description: Generate R documentation in Quarto format based on comments in R scripts.
Description: Generate R documentation in Quarto format based on comments in code files.
License: MIT + file LICENSE
Encoding: UTF-8
SystemRequirements: Quarto command line tools
Expand Down
19 changes: 19 additions & 0 deletions rdocs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Daniel Gurgel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 2 additions & 1 deletion rdocs/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export(generate_docs)
export(download_rdocs)
export(download_rdocs)
importFrom("utils", "download.file")

0 comments on commit 550b9e5

Please sign in to comment.