@graphql-markdown/printer-legacy
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"license": "MIT", | ||
@@ -11,0 +11,0 @@ "main": "src/index.js", |
@@ -6,6 +6,10 @@ const { | ||
const { MARKDOWN_EOL, DEPRECATED } = require("./const/strings"); | ||
const { | ||
MARKDOWN_EOL, | ||
DEPRECATED, | ||
MARKDOWN_CODE_INDENTATION, | ||
} = require("./const/strings"); | ||
const { OPTION_DEPRECATED } = require("./const/options"); | ||
const printCodeField = (type, options = {}) => { | ||
const printCodeField = (type, options = {}, indentationLevel = 0) => { | ||
const skipDirective = | ||
@@ -23,3 +27,3 @@ hasProperty(options, "skipDocDirective") && | ||
let code = `${getTypeName(type)}`; | ||
code += printCodeArguments(type); | ||
code += printCodeArguments(type, indentationLevel + 1); | ||
code += `: ${getTypeName(type.type)}`; | ||
@@ -32,3 +36,3 @@ code += isDeprecated(type) ? ` @${DEPRECATED}` : ""; | ||
const printCodeArguments = (type) => { | ||
const printCodeArguments = (type, indentationLevel = 1) => { | ||
if (!hasProperty(type, "args") || type.args.length === 0) { | ||
@@ -38,2 +42,5 @@ return ""; | ||
const argIndentation = MARKDOWN_CODE_INDENTATION.repeat(indentationLevel); | ||
const parentIndentation = | ||
indentationLevel === 1 ? "" : MARKDOWN_CODE_INDENTATION; | ||
let code = `(${MARKDOWN_EOL}`; | ||
@@ -47,5 +54,5 @@ code += type.args.reduce((r, v) => { | ||
const propName = v.name.toString(); | ||
return `${r} ${propName}: ${propType}${printedDefault}${MARKDOWN_EOL}`; | ||
return `${r}${argIndentation}${propName}: ${propType}${printedDefault}${MARKDOWN_EOL}`; | ||
}, ""); | ||
code += `)`; | ||
code += `${parentIndentation})`; | ||
@@ -52,0 +59,0 @@ return code; |
@@ -23,2 +23,3 @@ const ROOT_TYPE_LOCALE = { | ||
const MARKDOWN_EOC = `${MARKDOWN_EOL}\`\`\`${MARKDOWN_EOL}`; | ||
const MARKDOWN_CODE_INDENTATION = " "; | ||
const FRONT_MATTER = "---"; | ||
@@ -38,4 +39,5 @@ | ||
MARKDOWN_EOC, | ||
MARKDOWN_CODE_INDENTATION, | ||
FRONT_MATTER, | ||
DEPRECATED, | ||
}; |
@@ -8,3 +8,3 @@ const { | ||
const { printCodeField } = require("../code"); | ||
const { MARKDOWN_EOL } = require("../const/strings"); | ||
const { MARKDOWN_EOL, MARKDOWN_CODE_INDENTATION } = require("../const/strings"); | ||
@@ -42,4 +42,4 @@ const printInterfaceMetadata = (type, options) => { | ||
.map((field) => { | ||
const f = printCodeField(field, options); | ||
return f.length > 0 ? ` ${f}` : ""; | ||
const f = printCodeField(field, options, 1); | ||
return f.length > 0 ? `${MARKDOWN_CODE_INDENTATION}${f}` : ""; | ||
}) | ||
@@ -46,0 +46,0 @@ .filter((field) => field.length > 0) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36611
1105