diff options
| -rw-r--r-- | package.json | 5 | ||||
| -rw-r--r-- | src/CodeParser/CParser.ts | 11 | ||||
| -rw-r--r-- | src/Config.ts | 1 | ||||
| -rw-r--r-- | src/DocGen/CGen.ts | 14 |
4 files changed, 25 insertions, 6 deletions
diff --git a/package.json b/package.json index a5d6658..bbaf64d 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,11 @@ "/**", "/*!" ] + }, + "doxdocgen.generic.generateReturnType": { + "description": "Insert return type into generated documentation", + "type": "boolean", + "default": true } } } diff --git a/src/CodeParser/CParser.ts b/src/CodeParser/CParser.ts index 99d01fc..4889de6 100644 --- a/src/CodeParser/CParser.ts +++ b/src/CodeParser/CParser.ts @@ -1,4 +1,5 @@ -import { Position, TextDocumentContentChangeEvent, TextEditor, TextLine } from "vscode"; +import { Position, TextDocumentContentChangeEvent, TextEditor, TextLine, workspace } from "vscode"; +import { Config, ConfigType } from "../Config"; import Generator from "../DocGen/CGen"; import { IDocGen } from "../DocGen/DocGen"; import ICodeParser from "./CodeParser"; @@ -105,6 +106,14 @@ export default class CParser implements ICodeParser { break; } + // Don't generate return type if the user doesn't wish to do it + if (!workspace.getConfiguration(ConfigType.generic).get<boolean>(Config.generateReturnType, true) && + retVals.length > 0) { + retVals.length = 0; + retVals.push(" "); + return retVals; + } + return retVals; } diff --git a/src/Config.ts b/src/Config.ts index 92d208c..2e449cf 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -4,4 +4,5 @@ export enum ConfigType { export enum Config { commentStart = "commentStart", + generateReturnType = "generateReturnType", } diff --git a/src/DocGen/CGen.ts b/src/DocGen/CGen.ts index 5a80ee0..426bb26 100644 --- a/src/DocGen/CGen.ts +++ b/src/DocGen/CGen.ts @@ -110,13 +110,21 @@ export default class CGen implements IDocGen { } protected generateReturn() { + if (this.retVals.length === 0) { + return; + } let line: string = ""; + if (this.params.length !== 0) { + line = this.lineStart + "\n"; + this.comment += this.indentLine(line); + } + this.retVals.forEach((element: string) => { line = this.lineStart; line += this.commandIndicator; line += DoxygenCommands.return + " "; // TODO: Make this customizable - line += element + "\n"; + line += element.trim() + "\n"; this.comment += this.indentLine(line); }); } @@ -136,10 +144,6 @@ export default class CGen implements IDocGen { this.generateParams(); } if (this.retVals.length !== 0) { // Only if we have return values - if (this.params.length !== 0) { - const line: string = this.lineStart + "\n"; - this.comment += this.indentLine(line); - } this.generateReturn(); } this.generateEnd(); |