Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/HenrikBengtsson/RNativeAPI
R package: RNativeAPI - Documentation and Examples of the R Native API (Proof of Concept)
https://github.com/HenrikBengtsson/RNativeAPI
api c documentation examples help native package r
Last synced: 9 days ago
JSON representation
R package: RNativeAPI - Documentation and Examples of the R Native API (Proof of Concept)
- Host: GitHub
- URL: https://github.com/HenrikBengtsson/RNativeAPI
- Owner: HenrikBengtsson
- Created: 2018-10-30T18:29:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T19:09:27.000Z (over 1 year ago)
- Last Synced: 2024-08-13T07:13:58.452Z (4 months ago)
- Topics: api, c, documentation, examples, help, native, package, r
- Language: R
- Homepage: https://henrikbengtsson.github.io/RNativeAPI/
- Size: 407 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - HenrikBengtsson/RNativeAPI - R package: RNativeAPI - Documentation and Examples of the R Native API (Proof of Concept) (R)
README
# R package: RNativeAPI - Documentation and Examples of the R Native API
A proof-of-concept package documenting the R Native API via the built-in R help system. The help pages are written in Roxygen2 that are compiled to Rd format and then rendered by R as regular help pages.
_Disclaimer: This is just a proof of concept; I'm not claiming this is the best approach._
## Examples
### Help pages
#### HTML version
#### Text version
```r
> options(help_type = "text")
> ?RNativeAPI::getAttribgetAttrib package:RNativeAPI R Documentation
Gets and Sets an Attribute of an R Object
Description:
Gets and Sets an Attribute of an R Object
Usage:
getAttrib(vec, name)
setAttrib(vec, name, val)
Arguments:vec: (SEXP) An R object.
name: (SEXP) A character of length one.
val: (SEXP) An R object.
Value:
getAttrib() returns (SEXP) the value of attribute ‘name’.
setAttrib() returns (SEXP) a copy of R object ‘vec’ with attribute ‘name’ set.
C API:
SEXP getAttrib(SEXP vec, SEXP name)
SEXP setAttrib(SEXP vec, SEXP name, SEXP val)R API:
value <- attr(vec, name)
attr(vec, name) <- valSource:
Declaration: src/include/Rinternals.h
Implementation: src/main/attrib.c
```## Displaying functions
```r
> RNativeAPI::getAttrib
function (vec, name)
{
vec = SEXP
name = SEXP
return(SEXP)
}```
_Comment:_ By a customized class and `print()` method, the above can probably be presented much nice. With some efforts, it could even display the actual source code (there are already R packages providing functionalities for this).