Skip to content

Commit

Permalink
Dev (#1)
Browse files Browse the repository at this point in the history
* Updated the scripts, added env files, restuctured the repo

* updated readthedocs.yaml bin/runMe.sh

* updated mkdocs template

* updated mkdocs.yml, readthedocs.yml, envs and runMe.sh

* updated readthedocs.yaml

* rename mkdocs.yaml to mkdocs.yml in readthedocs.yaml

* Added multiple child Rmds and added the order of the files in configs

* updated workflow image code and updated config files

* updated mkdocs yaml

* fixed images source and updated configs
  • Loading branch information
ramsainanduri authored Feb 14, 2023
1 parent 5b87662 commit 566b170
Show file tree
Hide file tree
Showing 35 changed files with 1,902 additions and 1,049 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tmp

tmp

envs/*sif
envs/*simg
example_command.sh
*html
10 changes: 7 additions & 3 deletions .readthedocs.yml → .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 2

# Set the version of Python and other tools you might need
# build:
# os: ubuntu-22.04
# os: ubuntu-22.04
# tools:
# python: "3.10"

Expand All @@ -16,5 +16,9 @@ mkdocs:

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
install:
- requirements: docs/requirements.txt
# system_packages: true

# Build all formats
# formats: all
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# mkdocs_test
# Pipeline Documentation

This automatic documentation generation is a time-saving tool for developers and teams, as it eliminates the need to manually create and maintain documentation. It also helps ensure that documentation is up-to-date and consistent, as changes made to the pipeline.yaml file used for the document updation in a simple and easy way.

The pipeline.yaml file contains all the relevant information about the pipeline or tool, including the description, inputs, outputs, parameters, and usage. This information is used to generate the HTML and MD documents, which provide clear and detailed information about the pipeline or tool.

The HTML document is visually appealing and easy to navigate, with links to different sections and a search bar for quickly finding specific information. The MD document is plain text, but can be formatted with Markdown syntax for a more readable and structured format. The MD document can be uploaded to a readthedocs server for online documentation. It uses the mkdocs format, with the required "docs" folder and related files in the project root folder.

Additionally, the generated documentation also includes a table of contents for easy navigation, and sections for examples.

Overall, this repo helps improve the documentation process for pipelines and tools, making it easier for others to understand and use them.


# To build the container

Go to the env folder and ruh the script,
`bash get_containers.sh`

*Note: Creating containers requires sudo permission*

# To test

- Clone the repo to your local system.
- run the command like this,
`bash bin/runMe.sh -e`
- run the example command like given below,
`bash example_command.sh`
23 changes: 23 additions & 0 deletions bin/functions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
camel <- function(x){ #function for camel case
capit <- function(x) paste0(toupper(substring(x, 1, 1)), substring(x, 2, nchar(x)))
sapply(strsplit(as.character(x), "\\."), function(x) paste(capit(x), collapse=""))
}


round_df <- function(df, digits) {
nums <- vapply(df, is.numeric, FUN.VALUE = logical(1))

df[,nums] <- round(df[,nums], digits = digits)

return(df)
}

highlight_text <- function(x, color,weight="normal",type="normal") {
sprintf("<span style='color: %s;font-weight: %s;font-style: %s;'>%s</span>", color,weight,type,x)
}

get_unique_keys <- function(data) {#function to get unique keys from the data in yaml dict
unique_keys <- unique(gsub("\\..*","",colnames(as.data.frame(data))))
return(unique_keys)
}

12 changes: 12 additions & 0 deletions bin/info.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# Pipeline Info

```{r info, echo=FALSE,warning=FALSE, message=FALSE, results='asis'}
info_df = data.frame(t(data.frame(params$pipeline$info)))
info_df = cbind(rownames(info_df),info_df)
colnames(info_df) = c('Info','Description')
info_df$Info = camel(info_df$Info)
info_df$Info = paste('**',info_df$Info,'**',sep='')
kable(info_df,booktabs=TRUE, escape=FALSE,row.names=FALSE) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),full_width = F, position = "center")
```
3 changes: 3 additions & 0 deletions bin/introduction.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

`r params$pipeline$introduction`
83 changes: 83 additions & 0 deletions bin/main.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: '`r params$pipeline$info$name`'
output:
rmdformats::readthedown:
toc_depth: 5
toc_float: true
highlight: tango
fig_width: 7
fig_height: 6
fig_caption: true
keep_md: true
thumbnails: true
lightbox: false
gallery: false
url: blue
number_sections: true
author: '`r params$pipeline$info$author`'
link-citations: true
date: '`r Sys.Date()`'
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir = paste(params$pipeline$info$server_location,'tmp',sep='/'))
library(knitr)
library(rmarkdown)
library(kableExtra)
library(DT)
library(dplyr)
library(htmltools)
source(paste(root,'bin/functions.R', sep='/'))
```


```{r logo, echo=FALSE}
#htmltools::img(src = knitr::image_uri(params$pipeline$logo),
# alt = 'logo',
# style = 'position:absolute; top:0; left:0; padding:10px;')
#Still need to work on this
a = 1
```

```{r,echo = FALSE}
table_no = 1
figure_no = 1
```

```{r var, echo=FALSE,warning=FALSE, message=FALSE, results='asis'}
params_keys=get_unique_keys(params$pipeline)
child_rmds = c()
for (key in params_keys) {
if (key == 'logo') {
next
} else {
if (params$pipeline[key] != '') {
#child_rmds = append(child_rmds, paste(root,'/bin/', key,'.Rmd', sep=''))
child_rmds = append(child_rmds, paste(key,'.Rmd', sep=''))
}
}
}
```

```{r child documents, message=FALSE, warning=FALSE, echo=FALSE, results='asis'}
for (i in 1:length(child_rmds)) {
child_env <- new.env()
child_env$species <- "Adelie"
child_res <- knitr::knit_child(child_rmds[i], envir = child_env, quiet = TRUE)
cat(child_res, sep = '\n')
child_md_name=gsub('.*/', '', child_rmds[i])
child_md_name=gsub('Rmd$', 'md', child_md_name)
child_md_out = paste(params$pipeline$info$server_location,'/tmp/',child_md_name,sep='')
cat(child_res, file=child_md_out, sep = '\n')
}
```


11 changes: 11 additions & 0 deletions bin/min_requirements.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Minimum Requirements

```{r, echo=FALSE,warning=FALSE, message=FALSE, results='asis'}
min_req_df = data.frame(t(data.frame(params$pipeline$min_requirements)))
min_req_df = cbind(rownames(min_req_df),min_req_df)
colnames(min_req_df) = c('Name','Description')
min_req_df$Name = camel(min_req_df$Name)
min_req_df$Name = paste('**',min_req_df$Name,'**',sep='')
kable(min_req_df,booktabs=TRUE, escape=FALSE,row.names=FALSE) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),full_width = F, position = "center")
```
15 changes: 15 additions & 0 deletions bin/profiles.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Profiles

```{r profiles, echo=FALSE,warning=FALSE, message=FALSE, results='asis'}
profiles=get_unique_keys(params$pipeline$profiles)
res <- vector(mode = "list", length = length(profiles))
for (i in 1:length(profiles)) {
profile = profiles[i]
#res[i] <- knitr::knit_child(paste(root,'bin/profiles_child.Rmd',sep='/'), quiet = TRUE, envir = environment())
res[i] <- knitr::knit_child('profiles_child.Rmd', quiet = TRUE, envir = environment())
}
cat(unlist(res), sep = '\n')
```
38 changes: 38 additions & 0 deletions bin/profiles_child.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## `r profile`

**Profile Name:** `r params$pipeline$profiles[[profile]]$profile_name`

### Description

`r params$pipeline$profiles[[profile]]$profile_description`

### Usage

`r params$pipeline$profiles[[profile]]$profile_usage`


### Software Stack

```{r, echo=FALSE,warning=FALSE, message=FALSE, results='asis'}
software_list = read.table(file = params$pipeline$profiles[[profile]]$profile_software_list, sep = '\t', header = TRUE, stringsAsFactors = FALSE, check.names=F)
software_list = software_list[order(software_list$`Tool/Software`),]
software_list$ID <- seq.int(nrow(software_list))
software_list <- software_list %>% select(ID, everything())
software_list$`Tool/Software` = paste('<a href = "',software_list$URL,'" target="_blank">',software_list$`Tool/Software`,'</a>',sep='')
software_list$Reference = paste('<a href = "',software_list$Reference,'" target="_blank">open</a>',sep='')
software_list = select(software_list, -c(URL,'Short Description'))
kable(software_list,booktabs=TRUE, escape=FALSE,row.names=FALSE) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),full_width = F, position = "center")
```

### Validation Data

To validate the pipeline, please access the validation data stored on the server using the path provided below,

**`r params$pipeline$profiles[[profile]]$profile_validatation_data_path`**

### Test Data

To test the pipeline, please access the downsampled test data stored on the server using the path provided below,

**`r params$pipeline$profiles[[profile]]$profile_test_data_path`**
Loading

0 comments on commit 566b170

Please sign in to comment.