jsgen: proper jsdoc for namespace

pull/4982/head
Abdullah Atta 2020-05-21 19:31:07 +05:00 committed by GitHub
parent 26cb9e4b9f
commit cb82ff618b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -99,7 +99,7 @@ pub fn gen(files []ast.File, table &table.Table, pref &pref.Preferences) string
g.finish() g.finish()
mut out := g.hashes() + g.definitions.str() + g.constants.str() mut out := g.hashes() + g.definitions.str() + g.constants.str()
for node in deps_resolved.nodes { for node in deps_resolved.nodes {
out += '/* namespace: $node.name */\n' out += g.doc.gen_namespace(node.name)
out += 'const $node.name = (function (' out += 'const $node.name = (function ('
imports := g.namespace_imports[node.name] imports := g.namespace_imports[node.name]
for i, key in imports.keys() { for i, key in imports.keys() {

View File

@ -96,3 +96,9 @@ fn (mut d JsDoc) gen_fn(it ast.FnDecl) string {
d.write('*/') d.write('*/')
return d.out.str() return d.out.str()
} }
fn (mut d JsDoc) gen_namespace(ns string) string {
d.reset()
d.writeln('/** @namespace ${ns} */')
return d.out.str()
}