Comparing version 1.11.1 to 1.12.0
@@ -133,4 +133,3 @@ let extractTags = require('rexml'); if (extractTags && extractTags.__esModule) extractTags = extractTags.default; | ||
const t = (closure ? this.closureType : this.type) || 'Object' | ||
const d = this.description ? ` ${this.description}` : '' | ||
const dd = ` ${this.getFullNameForExtends(closure)}${d}` | ||
const dd = ` ${this.getFullNameForExtends(closure)}${this.descriptionWithTag}` | ||
const s = ` * @typedef {${t}}${dd}` | ||
@@ -146,4 +145,8 @@ const p = this.properties ? this.properties.map((pr) => { | ||
} | ||
get descriptionWithTag() { | ||
const d = this.description ? ` ${this.description}` : '' | ||
const t = this.tag ? ` \`@${this.tag}\`` : '' | ||
return `${t}${d}` | ||
} | ||
toTypedef(closure = false, noSuppress = false) { | ||
const d = this.description ? ` ${this.description}` : '' | ||
const hasExtends = !!this.extends | ||
@@ -161,3 +164,3 @@ const natural = this.toNaturalTypedef(closure, noSuppress) | ||
if (this.namespace && closure) { | ||
let td = ` * @typedef {${this.fullName}} ${this.name}${d}` | ||
let td = ` * @typedef {${this.fullName}} ${this.name}${this.descriptionWithTag}` | ||
if (closure && !noSuppress) td = addSuppress(td) | ||
@@ -168,3 +171,3 @@ td = makeBlock(td) | ||
if (hasExtends) { | ||
let extended = ` * @typedef {${this.extends} & ${this.getFullNameForExtends(closure)}} ${closure ? this.fullName : this.name}${d}` | ||
let extended = ` * @typedef {${this.extends} & ${this.getFullNameForExtends(closure)}} ${closure ? this.fullName : this.name}${this.descriptionWithTag}` | ||
if (closure && !noSuppress) extended = addSuppress(extended) | ||
@@ -179,7 +182,16 @@ extended = makeBlock(extended) | ||
get prototypeAnnotation() { | ||
const tag = this.tag | ||
if (!tag) | ||
throw new Error('Unknown prototype type (not constructor or interface).') | ||
return tag | ||
} | ||
get tag() { | ||
if (this.isConstructor) return 'constructor' | ||
if (this.isInterface) return 'interface' | ||
if (this.isRecord) return 'record' | ||
throw new Error('Unknown prototype type (not constructor or interface).') | ||
return '' | ||
} | ||
/** | ||
* Only used in externs. | ||
*/ | ||
toPrototype() { | ||
@@ -186,0 +198,0 @@ const pp = [] |
## 1 May 2019 | ||
### [1.12.0](https://github.com/artdecocode/typal/compare/v1.11.1...v1.12.0) | ||
- [feature] Add tags (`@constructor/record/interface`) to JSDoc typedefs' description. | ||
### [1.11.1](https://github.com/artdecocode/typal/compare/v1.11.0...v1.11.1) | ||
@@ -4,0 +8,0 @@ |
@@ -162,6 +162,6 @@ #!/usr/bin/env node | ||
b = (delete c.binary, delete c.rs, c); | ||
const {J:f = G(!0), proxyError:g} = a || {}, h = (k, l) => f(l); | ||
const {K:f = G(!0), proxyError:g} = a || {}, h = (k, l) => f(l); | ||
super(b); | ||
this.a = []; | ||
this.H = new Promise((k, l) => { | ||
this.I = new Promise((k, l) => { | ||
this.on("finish", () => { | ||
@@ -191,3 +191,3 @@ let m; | ||
get g() { | ||
return this.H; | ||
return this.I; | ||
} | ||
@@ -197,3 +197,3 @@ } | ||
var b = void 0 === b ? {} : b; | ||
({g:a} = new va(Object.assign({}, {rs:a}, b, {J:G(!0)}))); | ||
({g:a} = new va(Object.assign({}, {rs:a}, b, {K:G(!0)}))); | ||
return await a; | ||
@@ -294,3 +294,3 @@ }; | ||
return `${a}=${b}`; | ||
}, za = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", Q = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, Aa = a => `/** | ||
}, za = ({number:a, N:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", Q = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, Aa = a => `/** | ||
${a} | ||
@@ -327,3 +327,3 @@ */ | ||
d = e.replace(/\/$/, "").trim(); | ||
d = {v:Ca(d), content:f}; | ||
d = {w:Ca(d), content:f}; | ||
c.push(d); | ||
@@ -508,3 +508,3 @@ } | ||
b && (a.description = b.trim()); | ||
a.type = za({number:g, L:d, boolean:e, type:h}); | ||
a.type = za({number:g, N:d, boolean:e, type:h}); | ||
l ? a.b = l : a.b = a.type; | ||
@@ -549,12 +549,12 @@ void 0 !== k && (a.a = !0); | ||
e && (a.description = e.trim()); | ||
a.G = !!f; | ||
a.o = !!g; | ||
a.m = !!h; | ||
a.H = !!f; | ||
a.G = !!g; | ||
a.v = !!h; | ||
a.import = !!k; | ||
l && (a.link = l); | ||
!0 === n && (a.isConstructor = n); | ||
!0 === q && (a.a = q); | ||
!0 === r && (a.g = r); | ||
!0 === q && (a.l = q); | ||
!0 === r && (a.m = r); | ||
p && (a.extends = p); | ||
b && (a.f = U("prop", b).map(({content:w, v:Ua}) => { | ||
b && (a.f = U("prop", b).map(({content:w, w:Ua}) => { | ||
const Z = new Ja; | ||
@@ -570,3 +570,3 @@ Ha(Z, w, Ua); | ||
a.extends && b.push(` * @extends {${a.extends}}`); | ||
b.push(` * @${a.C}`); | ||
b.push(` * @${a.L}`); | ||
b = `/** | ||
@@ -596,6 +596,6 @@ ${b.join("\n")} | ||
const c = `${a.extends ? "$" : ""}${a.name}`; | ||
return b ? `${a.l}${c}` : c; | ||
return b ? `${a.o}${c}` : c; | ||
} | ||
function Ma(a, b, c) { | ||
var d = ` * @typedef {${(b ? a.b : a.type) || "Object"}}${` ${La(a, b)}${a.description ? ` ${a.description}` : ""}`}`; | ||
var d = ` * @typedef {${(b ? a.b : a.type) || "Object"}}${` ${La(a, b)}${a.g}`}`; | ||
a = a.f ? a.f.map(e => Ia(e, b)) : []; | ||
@@ -610,18 +610,18 @@ d = [d, ...a].join("\n"); | ||
function Na(a, b = !1, c = !1) { | ||
const d = a.description ? ` ${a.description}` : "", e = !!a.extends, f = Ma(a, b, c), g = []; | ||
const d = !!a.extends, e = Ma(a, b, c), f = []; | ||
if (a.i && b) { | ||
let h = ` * @typedef {${a.c}} ${a.name}${d}`; | ||
b && !c && (h = R(h)); | ||
h = `/** | ||
${h} | ||
let g = ` * @typedef {${a.c}} ${a.name}${a.g}`; | ||
b && !c && (g = R(g)); | ||
g = `/** | ||
${g} | ||
*/ | ||
`; | ||
g.push(h); | ||
f.push(g); | ||
} | ||
e && (a = ` * @typedef {${a.extends} & ${La(a, b)}} ${b ? a.c : a.name}${d}`, b && !c && (a = R(a)), a = `/** | ||
d && (a = ` * @typedef {${a.extends} & ${La(a, b)}} ${b ? a.c : a.name}${a.g}`, b && !c && (a = R(a)), a = `/** | ||
${a} | ||
*/ | ||
`, g.push(a)); | ||
g.push(f); | ||
return g.join(""); | ||
`, f.push(a)); | ||
f.push(e); | ||
return f.join(""); | ||
} | ||
@@ -631,28 +631,29 @@ class X { | ||
this.name = ""; | ||
this.link = this.m = this.import = this.o = this.G = this.description = this.b = this.type = null; | ||
this.link = this.v = this.import = this.G = this.H = this.description = this.b = this.type = null; | ||
this.f = []; | ||
this.i = null; | ||
this.g = this.a = this.isConstructor = !1; | ||
this.m = this.l = this.isConstructor = !1; | ||
this.extends = null; | ||
} | ||
get K() { | ||
return this.isConstructor || this.a || this.g; | ||
get M() { | ||
return this.isConstructor || this.l || this.m; | ||
} | ||
get C() { | ||
if (this.isConstructor) { | ||
return "constructor"; | ||
get g() { | ||
return `${this.a ? ` \`@${this.a}\`` : ""}${this.description ? ` ${this.description}` : ""}`; | ||
} | ||
get L() { | ||
const a = this.a; | ||
if (!a) { | ||
throw Error("Unknown prototype type (not constructor or interface)."); | ||
} | ||
if (this.a) { | ||
return "interface"; | ||
} | ||
if (this.g) { | ||
return "record"; | ||
} | ||
throw Error("Unknown prototype type (not constructor or interface)."); | ||
return a; | ||
} | ||
get l() { | ||
get a() { | ||
return this.isConstructor ? "constructor" : this.l ? "interface" : this.m ? "record" : ""; | ||
} | ||
get o() { | ||
return this.i ? `${this.i}.` : ""; | ||
} | ||
get c() { | ||
return `${this.l}${this.name}`; | ||
return `${this.o}${this.name}`; | ||
} | ||
@@ -663,5 +664,5 @@ F(a, b, c, d, e = !1) { | ||
d = this.description ? ` ${this.description}` : ""; | ||
const g = this.o ? Oa(this.f) : e ? this.c : this.name; | ||
const g = this.G ? Oa(this.f) : e ? this.c : this.name; | ||
b = `${c || ""} * @param {${f}${g}} ${b ? `[${a}]` : a}${d}`; | ||
f = this.f && !this.m ? this.f.map(h => h.F(a, c, e)) : []; | ||
f = this.f && !this.v ? this.f.map(h => h.F(a, c, e)) : []; | ||
return [b, ...f].join("\n"); | ||
@@ -706,8 +707,8 @@ } | ||
super(b); | ||
this.m = (Array.isArray(a) ? a : [a]).filter(Pa); | ||
this.l = (Array.isArray(a) ? a : [a]).filter(Pa); | ||
this.a = !1; | ||
this.C = b; | ||
this.v = b; | ||
} | ||
async replace(a, b) { | ||
const c = new Sa(this.m, this.C); | ||
const c = new Sa(this.l, this.v); | ||
b && Object.assign(c, b); | ||
@@ -725,3 +726,3 @@ a = await Ra(c, a); | ||
async reduce(a) { | ||
return await this.m.reduce(async(b, {re:c, replacement:d}) => { | ||
return await this.l.reduce(async(b, {re:c, replacement:d}) => { | ||
b = await b; | ||
@@ -788,5 +789,5 @@ if (this.a) { | ||
a.from = c; | ||
a.A = d; | ||
a.B = d; | ||
a.link = e; | ||
a.l = f || a.from; | ||
a.o = f || a.from; | ||
} | ||
@@ -798,7 +799,7 @@ function Xa(a, b = !0) { | ||
constructor() { | ||
this.from = this.name = this.l = ""; | ||
this.link = this.A = null; | ||
this.from = this.name = this.o = ""; | ||
this.link = this.B = null; | ||
} | ||
get c() { | ||
return `${this.l}.${this.name}`; | ||
return `${this.o}.${this.name}`; | ||
} | ||
@@ -808,3 +809,3 @@ } | ||
b = b.reduce((c, d) => Object.assign({}, c, {[d.c]:d}), {}); | ||
a.w = Object.assign({}, a.w, b); | ||
a.A = Object.assign({}, a.A, b); | ||
} | ||
@@ -815,3 +816,3 @@ class $a extends Sa { | ||
super(a); | ||
this.w = {}; | ||
this.A = {}; | ||
this.on("types", c => { | ||
@@ -823,3 +824,3 @@ Za(this, c); | ||
}); | ||
this.o = b; | ||
this.m = b; | ||
this.g = []; | ||
@@ -837,3 +838,3 @@ this.h = console.log; | ||
get types() { | ||
return this.w; | ||
return this.A; | ||
} | ||
@@ -846,4 +847,4 @@ } | ||
} | ||
const [{content:b, v:{namespace:c, ns:d = c}}] = a, e = void 0 == d ? void 0 : d; | ||
a = U("type", b).map(({content:h, v:k}) => { | ||
const [{content:b, w:{namespace:c, ns:d = c}}] = a, e = void 0 == d ? void 0 : d; | ||
a = U("type", b).map(({content:h, w:k}) => { | ||
const l = new X; | ||
@@ -853,12 +854,12 @@ W(l, h, k, e); | ||
}); | ||
const f = U("import", b).map(({v:h}) => { | ||
const f = U("import", b).map(({w:h}) => { | ||
const k = new Ya; | ||
Wa(k, h); | ||
return k; | ||
}), g = f.map(({name:h, from:k, A:l, link:m, l:n}) => { | ||
}), g = f.map(({name:h, from:k, B:l, link:m, o:n}) => { | ||
const p = new X; | ||
W(p, "", {name:h, type:`import('${k}').${h}`, G:!0, import:!0, A:l, link:m}, void 0 == n ? void 0 : n); | ||
W(p, "", {name:h, type:`import('${k}').${h}`, H:!0, import:!0, B:l, link:m}, void 0 == n ? void 0 : n); | ||
return p; | ||
}); | ||
return {i:d, types:a, imports:f, M:g}; | ||
return {i:d, types:a, imports:f, O:g}; | ||
}; | ||
@@ -879,3 +880,3 @@ const bb = (a, b, c) => { | ||
let e; | ||
d.b ? e = ` * @typedef {${d.b}}` : d.K || (e = ` * @typedef {${Oa(d.f, !0)}}`); | ||
d.b ? e = ` * @typedef {${d.b}}` : d.M || (e = ` * @typedef {${Oa(d.f, !0)}}`); | ||
e ? (d.description && (e = ` * ${d.description}\n${e}`), e = `/** | ||
@@ -896,3 +897,3 @@ ${e} | ||
k = k ? k.replace("ignore:", "").split(",") : []; | ||
let {u:l, B:m} = this.o; | ||
let {u:l, C:m} = this.m; | ||
f && (l = !0); | ||
@@ -922,3 +923,3 @@ g && (m = !0); | ||
function gb(a, b, c, d, e, f, g) { | ||
const {u:h} = this.o; | ||
const {u:h} = this.m; | ||
let k; | ||
@@ -933,5 +934,5 @@ f = () => { | ||
} | ||
m = {line:m, I:b.length + 11}; | ||
m = {line:m, J:b.length + 11}; | ||
} | ||
const {line:n, I:p} = m; | ||
const {line:n, J:p} = m; | ||
this.h("%s:%s:%s", this.file, n, p); | ||
@@ -980,3 +981,3 @@ } | ||
var jb = async() => { | ||
const {u:a = !1, B:b = !1, D:c, types:d} = {u:ca, B:da, D:z, types:ea}; | ||
const {u:a = !1, C:b = !1, D:c, types:d} = {u:ca, C:da, D:z, types:ea}; | ||
await Promise.all(y.map(async e => { | ||
@@ -998,3 +999,3 @@ var f = await L(A, e); | ||
var h = await I(g); | ||
const k = new $a([eb, hb], {u:b, B:c}); | ||
const k = new $a([eb, hb], {u:b, C:c}); | ||
f.forEach(l => k.emit("types", l)); | ||
@@ -1001,0 +1002,0 @@ k.file = g; |
{ | ||
"name": "typal", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"description": "Organises TypeDefs By Placing Them Into Types.Xml File To Be Embedded Into Source Code Compatible With VSCode And Google Closure Compiler, Generates Externs And Allows To Place Documentation In README Markdown.", | ||
@@ -70,2 +70,3 @@ "main": "build/index.js", | ||
"@wrote/write": "^1.0.4", | ||
"@zoroaster/mask": "^2.0.4", | ||
"alamode": "^2.0.0", | ||
@@ -72,0 +73,0 @@ "argufy": "^1.7.0", |
@@ -133,4 +133,3 @@ import extractTags from 'rexml' | ||
const t = (closure ? this.closureType : this.type) || 'Object' | ||
const d = this.description ? ` ${this.description}` : '' | ||
const dd = ` ${this.getFullNameForExtends(closure)}${d}` | ||
const dd = ` ${this.getFullNameForExtends(closure)}${this.descriptionWithTag}` | ||
const s = ` * @typedef {${t}}${dd}` | ||
@@ -146,4 +145,8 @@ const p = this.properties ? this.properties.map((pr) => { | ||
} | ||
get descriptionWithTag() { | ||
const d = this.description ? ` ${this.description}` : '' | ||
const t = this.tag ? ` \`@${this.tag}\`` : '' | ||
return `${t}${d}` | ||
} | ||
toTypedef(closure = false, noSuppress = false) { | ||
const d = this.description ? ` ${this.description}` : '' | ||
const hasExtends = !!this.extends | ||
@@ -161,3 +164,3 @@ const natural = this.toNaturalTypedef(closure, noSuppress) | ||
if (this.namespace && closure) { | ||
let td = ` * @typedef {${this.fullName}} ${this.name}${d}` | ||
let td = ` * @typedef {${this.fullName}} ${this.name}${this.descriptionWithTag}` | ||
if (closure && !noSuppress) td = addSuppress(td) | ||
@@ -168,3 +171,3 @@ td = makeBlock(td) | ||
if (hasExtends) { | ||
let extended = ` * @typedef {${this.extends} & ${this.getFullNameForExtends(closure)}} ${closure ? this.fullName : this.name}${d}` | ||
let extended = ` * @typedef {${this.extends} & ${this.getFullNameForExtends(closure)}} ${closure ? this.fullName : this.name}${this.descriptionWithTag}` | ||
if (closure && !noSuppress) extended = addSuppress(extended) | ||
@@ -179,7 +182,16 @@ extended = makeBlock(extended) | ||
get prototypeAnnotation() { | ||
const tag = this.tag | ||
if (!tag) | ||
throw new Error('Unknown prototype type (not constructor or interface).') | ||
return tag | ||
} | ||
get tag() { | ||
if (this.isConstructor) return 'constructor' | ||
if (this.isInterface) return 'interface' | ||
if (this.isRecord) return 'record' | ||
throw new Error('Unknown prototype type (not constructor or interface).') | ||
return '' | ||
} | ||
/** | ||
* Only used in externs. | ||
*/ | ||
toPrototype() { | ||
@@ -186,0 +198,0 @@ const pp = [] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
258637
3678
18