Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bergant/rmdoc
R Markdown Template for Software Documentation
https://github.com/bergant/rmdoc
Last synced: 23 days ago
JSON representation
R Markdown Template for Software Documentation
- Host: GitHub
- URL: https://github.com/bergant/rmdoc
- Owner: bergant
- License: other
- Created: 2016-05-18T14:10:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-21T11:04:28.000Z (about 8 years ago)
- Last Synced: 2024-08-13T07:11:28.584Z (4 months ago)
- Language: R
- Size: 66.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - bergant/rmdoc - R Markdown Template for Software Documentation (R)
README
---
title: rmdoc - R Markdown Software Documentation
output:
html_document:
keep_md: yes
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```Provides:
- Functionality to extract data model diagrams from databases
- RStudio AddIn for rendering data model diagrams from yaml
- R Markdown template## Installation
```{r eval=FALSE}
devtools::install_github("bergant/datamodelr")
devtools::install_github("bergant/rmdoc")
```## Setup
Add connection strings for databases in your .Renviron file like this:
```
RMDOC_CON_STRING_xxxxx=Driver={SQL Server};Server=ssssss;Database=ddddd;Uid=***;Pwd=***
RMDOC_CON_STRING_yyyyy=Driver={SQL Server};Server=eeeeee;Database=aaaaa;Uid=***;Pwd=***
```where xxxxx and yyyyyy are your "logical" database names.
## Usage
### Default Database Connection
Add parameters to your rmd file yaml header (which database is used by default):```yaml
params:
database: xxxxx
```Include the following knitr chunk before your content:
```{r database_setup, cache=TRUE, eval=FALSE}
if(!is.null(params$database)) {
.rmdoc_db_meta <- get_db_meta(database = params$database)
}
```### Draw Data Model Diagrams
Draw datamodel diagrams like this:
```{r eval=FALSE}
display_graph(
get_graph_from_yaml("my_data_model.yml")
)
```The yaml should be in this format:
```yaml
# reverse engineer existing tables:
- extract_to: some_diagram_segment
tables:
- Suppliers
- Products# draw new tables (not in the database):
- table: Order Line
segment: "Transactions"
columns:
Order ID: {key: yes, ref: Order}
Line number: {key: yes}
Order item: {ref: Item}
Quantity:
Price:
```You can preview the data model in RStudio:
open your yaml file and select from menu Addins/Preview Data Model
### Display Data from Database```{r eval=FALSE}
some_data <- get_database_data(params$database, "select * from MY_CODE_TABLE")
knitr::kable(some_data)```
## License
MIT