Skip to content

Commit

Permalink
disable HTML-escaping behavior globally
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipNelson5 committed Apr 2, 2024
1 parent 9c6ed72 commit ca5ff16
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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

0 comments on commit ca5ff16

Please sign in to comment.