Comparing version 0.2.1 to 0.3.0
@@ -9,10 +9,10 @@ export declare class DocuPorter { | ||
appendText(...text: string[]): void; | ||
appendCode(code: string, lang?: string): void; | ||
appendCode(code: string, lang?: string, comment?: string): void; | ||
appendJson(json: any): void; | ||
appendJs(js: string): void; | ||
appendTs(ts: any): void; | ||
appendJs(js: string, comment?: string): void; | ||
appendTs(ts: any, comment?: string): void; | ||
text: (...text: string[]) => void; | ||
json: (json: any) => void; | ||
js: (js: string) => void; | ||
ts: (ts: any) => void; | ||
js: (js: string, comment?: string) => void; | ||
ts: (ts: any, comment?: string) => void; | ||
header: (header: string, order?: 1 | 2 | 3 | 4 | 5) => void; | ||
@@ -19,0 +19,0 @@ h1: (header: string) => void; |
@@ -34,7 +34,8 @@ "use strict"; | ||
appendText(...text) { | ||
this.append(`${text.join(' ')}\n`); | ||
// use :: to start/end inline code blocks | ||
this.append(`${text.map(s => s.replace(/::/g, '`')).join(' ')}\n`); | ||
} | ||
appendCode(code, lang = '') { | ||
appendCode(code, lang = '', comment = '') { | ||
const codeBlock = '```'; | ||
this.append(`${codeBlock}${lang}\n${code}\n${codeBlock}\n`); | ||
this.append(`${codeBlock}${lang}\n${comment.length ? `// ${comment}\n\n` : ''}${code}\n${codeBlock}\n`); | ||
} | ||
@@ -44,7 +45,7 @@ appendJson(json) { | ||
} | ||
appendJs(js) { | ||
this.appendCode(js, 'JavaScript'); | ||
appendJs(js, comment) { | ||
this.appendCode(js, 'javascript', comment); | ||
} | ||
appendTs(ts) { | ||
this.appendCode(ts, 'TypeScrypt'); | ||
appendTs(ts, comment) { | ||
this.appendCode(ts, 'typescript', comment); | ||
} | ||
@@ -51,0 +52,0 @@ mute(value) { |
{ | ||
"name": "docuporter", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Understand a file by documenting it in a markdown file", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
3781
98