Skip to main content
Deno 2 is finally here 🎉️
Learn more

js_to_markdown logo

js -> markdown (documentation)

this is handy if you want to have the description of the usage of your code directyly in your testing source code javascript

//readme_custom.md:start
//md: # f_add 
//md: this is a function that adds two numbers
let n1 = 1;
let n2 = 2;
let f_add=(n1,n2)=>{return n1+n2}
//readme_custom.md:end
//this will not be present in the markdown since we closed the file with [filename.md]:end
//readme_custom.md:start
//md: # f_sub
//md: this is 
//md: `f_sub`, can be used to subtract numbers
let f_sub(n1,n2)=>{return n1-n2}

//md: ## usage
let b = 3 == f_add(1,2);
let b = 2 == f_sub(8,6);
//readme_custom.md:end

the file readme_custom.md was generated by inputing the content from this file into it

run directly from deno.land/x

deno run -A https://deno.land/x/f_generate_markdown@0.8/generate_from_console_argument.js my_js_file.js

run with function import

import {
    f_generate_markdown, 
    f_generate_markdown__from_s
}
await f_generate_markdown('./path/to/my_programm.js');
// or from a string
await f_generate_markdown__from_s(
`
//readme.md:start
//md: # this is cool
//md: yay
//readme.md:end
`
)