Roland Brand
Software engineer | Co-Founder of docgrandma | Rustacean | Part-time-preneur passionate about code tools, open source and digital business ideas
Rust Basel 2020-12-07
To improve documentation of software projects effortlessly
All code has documentation debt. Dev teams have three options:
Regularly ask developers specific, brief doc questions that are fun to answer.
Sustainably reduce documentation debt one question at a time.
Source: https://www.quora.com/Why-are-coders-so-bad-at-writing-documentation-that-is-easy-to-understand-for-the-average-human-programmer
? 👥
WHITESPACE = _{ " " | "\t" | "\r" | "\n" }
// top level rule
file = {
SOI
~ (import_stmt)*
~ (doc_node)*
~ EOI
}
doc_node = {
(import_stmt)*
~ block_comment?
~ (import_stmt)*
~ block
}
block_comment = { "/*" ~ (!"*/" ~ ANY)* ~ "*/" }
block = { (function | typedef) ~ block_body }
block_body = { "{" ~ "}" | "{" ~ body_inner* ~ "}" }
use crate::scanner::DocNode;
use std::fs;
use regex::Regex;
use regex::escape;
use regex::Split;
use std::env::current_dir;
pub fn commit(mut new_comment: String, doc_node: DocNode, pwd: &str) {
let mut complete_file = fs::read_to_string(&doc_node.file).unwrap();
// construct the comment from new_comment
new_comment = "/*\n * ".to_owned() + &new_comment + " \n */\n";
let sandwich: Vec<&str> = complete_file.split(&doc_node.code).collect();
assert!(sandwich.len() == 2);
let complete_file = sandwich[0].to_owned() + &new_comment + &doc_node.code + sandwich[1];
fs::write(&doc_node.file, complete_file).unwrap();
use std::process::Command;
let cmd = format!(
"cd {} && git add {} && git -c core.hooksPath=/dev/null commit -m 'a little improvement by docgrandma'",
pwd,
&doc_node.file.to_str().expect("not found")
);
Command::new("bash")
.arg("-c")
.arg(cmd)
.output()
.expect("some error with the commit");
}
By Roland Brand
Software engineer | Co-Founder of docgrandma | Rustacean | Part-time-preneur passionate about code tools, open source and digital business ideas