Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the mustache, HTML-escaping behavior #281

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Added doxygen format support ([#120](https://github.com/NilsJPWerner/autoDocstring/issues/120)) (@daluar @PhilipNelson5)
- Disable HTML-escaping behavior globally ([#253](https://github.com/NilsJPWerner/autoDocstring/issues/253)) (@PhilipNelson5)

[All Changes](https://github.com/NilsJPWerner/autoDocstring/compare/v0.6.1...master)

Expand Down
4 changes: 4 additions & 0 deletions src/docstring/docstring_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { render } from "mustache";
import { DocstringParts } from "../docstring_parts";
import { TemplateData } from "./template_data";
import { dedent } from "ts-dedent";
import Mustache = require("mustache");

// Disable HTML-escaping behavior globally
Mustache.escape = (text: string) => text;

export class DocstringFactory {
private template: string;
Expand Down
16 changes: 16 additions & 0 deletions src/test/docstring/generate_docstring.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ describe("DocstringFactory", () => {
});
});

context("when there are args", () => {
const template = "{{#args}}{{var}}:{{typePlaceholder}}{{/args}}";

it("should format Literals correctly", () => {
const docstringComponents = defaultDocstringComponents;
docstringComponents.args = [
{ var: "var_a", type: 'Literal["A", "B"]' },
];
const factory = new DocstringFactory(template);

const result = factory.generateDocstring(docstringComponents);

expect(result).to.equal('"""var_a:${1:Literal["A", "B"]}"""');
});
});

context("when the argsExist tag is used", () => {
const template = "{{#argsExist}}Args Exist!{{/argsExist}}";

Expand Down
Loading