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

Support doxygen file from java sources. #47

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
'enum',
// 'enumvalue',
'func',
// 'variable',
'var',
'property',
'public-attrib',
'public-func',
Expand All @@ -51,7 +51,7 @@ module.exports = {
'class',
'struct',
'union',
'typedef',
'typedef'
// 'file'
]
}
Expand All @@ -70,6 +70,18 @@ module.exports = {
if (options.templates == this.defaultOptions.templates)
options.templates = path.join(__dirname, 'templates', options.language);

switch(options.language) {
case 'java':
options.filters.compounds.push('interface');
options.filters.compounds.push('enum');
options.filters.members.splice(1,1);
options.filters.members.push('public-static-attrib');
options.filters.members.push('public-static-func');
break;
default:
break;
}

// Load templates
templates.registerHelpers(options);
templates.load(options.templates);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moxygen",
"version": "0.8.0",
"version": "0.8.1",
"description": "Doxygen XML to Markdown documentation converter",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 9 additions & 3 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
var link = f.match(/\[(.*)\]\((.*)\)/);
if (link) {
isInline ? (s += '`') && (isInline = false) : null;
s += '[`' + link[1] + '`](' + link[2] + ')';
s += ' [`' + link[1] + '`](' + link[2] + ')';
}
}
else if (f == '\n' || f == ' \n') {
Expand Down Expand Up @@ -83,7 +83,11 @@ module.exports = {
return '#' + refid;
return this.compoundPath(ref, options) + '#' + refid;
} else if (options.classes) {
var dest = this.findParent(ref, ['namespace', 'class', 'struct']);
var filtered = ['namespace', 'class', 'struct'];
if (options.language == 'java') {
filtered.concat(['interface', 'enum']);
}
var dest = this.findParent(ref, filtered);
if (!dest || compound.refid == dest.refid)
return '#' + refid;
return this.compoundPath(dest, options) + '#' + refid;
Expand All @@ -109,7 +113,9 @@ module.exports = {

writeCompound: function(compound, contents, references, options) {
this.writeFile(this.compoundPath(compound, options), contents.map(function(content) {
return this.resolveRefs(content, compound, references, options);
if (content) {
return this.resolveRefs(content, compound, references, options);
}
}.bind(this)));
},

Expand Down
60 changes: 41 additions & 19 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ module.exports = {
m = m.concat(toMarkdown(memberdef.type), ' ');
// m = m.concat(memberdef.name[0]._);
m = m.concat(markdown.refLink(member.name, member.refid));
m = m.concat(memberdef.initializer ? memberdef.initializer[0]._ : '');
break;

case 'property':
Expand Down Expand Up @@ -351,6 +352,10 @@ module.exports = {
});
},

assignToClass: function(compound, child) {
compound.compounds[child.id] = child;
},

extractPageSections: function(page, elements) {
elements.forEach(function(element) {
if (element['#name'] == 'sect1' || element['#name'] == 'sect2' || element['#name'] == 'sect3') {
Expand Down Expand Up @@ -427,6 +432,8 @@ module.exports = {
case 'struct':
case 'union':
case 'typedef':
case 'interface':
case 'enum':

// set namespace reference
var nsp = compound.name.split('::');
Expand All @@ -450,30 +457,14 @@ module.exports = {
compound.groupname = compound.name;
}

// handle innerclass for groups and namespaces
if (compounddef.innerclass) {
compounddef.innerclass.forEach(function (innerclassdef) {
if (compound.kind == 'namespace') {
// log.verbose('Assign ' + innerclassdef.$.refid + ' to namespace ' + compound.name);

if (this.references[innerclassdef.$.refid])
this.assignToNamespace(compound, this.references[innerclassdef.$.refid]);
}
else if (compound.kind == 'group') {
// log.verbose('Assign ' + innerclassdef.$.refid + ' to group ' + compound.name);
if (this.references[innerclassdef.$.refid])
this.assignClassToGroup(compound, this.references[innerclassdef.$.refid]);
}
}.bind(this));
}

// handle innernamespace for groups and namespaces
if (compounddef.innernamespace) {
compound.innernamespaces = [];
compounddef.innernamespace.forEach(function (namespacedef) {
if (compound.kind == 'group') {
// log.verbose('Assign namespace ' + namespacedef.$.refid + ' to group ' + compound.name);
this.assignNamespaceToGroup(compound, this.references[namespacedef.$.refid]);
if (this.references[namespacedef.$.refid])
this.assignNamespaceToGroup(compound, this.references[namespacedef.$.refid]);
}
}.bind(this));
}
Expand All @@ -482,6 +473,35 @@ module.exports = {
console.assert(true);
}

switch(compound.kind) {
case 'class':
case 'interface':
case 'enum':
case 'namespace':
case 'group':
// handle innerclass for groups and namespaces and 'class'.
if (compounddef.innerclass) {
compounddef.innerclass.forEach(function (innerclassdef) {
if (compound.kind == 'namespace') {
// log.verbose('Assign ' + innerclassdef.$.refid + ' to namespace ' + compound.name);

if (this.references[innerclassdef.$.refid])
this.assignToNamespace(compound, this.references[innerclassdef.$.refid]);
} else if (compound.kind == 'group') {
// log.verbose('Assign ' + innerclassdef.$.refid + ' to group ' + compound.name);
if (this.references[innerclassdef.$.refid])
this.assignClassToGroup(compound, this.references[innerclassdef.$.refid]);
} else if (compound.kind == 'class' || compound.kind == 'interface' || compound.kind == 'enum') {
if (this.references[innerclassdef.$.refid])
this.assignToClass(compound, this.references[innerclassdef.$.refid]);
}
}.bind(this));
}
break;
default:
break;
}

return;
},

Expand Down Expand Up @@ -526,7 +546,9 @@ module.exports = {
return;
}
this.root.kind = 'index';
this.parseIndex(this.root, result.doxygenindex.compound, options);
this.parseIndex(this.root, result.doxygenindex.compound.sort(function(a, b){
return b.$.refid.length - a.$.refid.length;
}), options);
callback(null, this.root); // TODO: return errors properly
}.bind(this));
}.bind(this));
Expand Down
2 changes: 2 additions & 0 deletions src/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ module.exports = {
break;
case 'class':
case 'struct':
case 'interface':
case 'enum':
template = 'class';
break;
default:
Expand Down
48 changes: 48 additions & 0 deletions templates/java/class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# {{kind}} `{{name}}` {{anchor refid}}

{{#if basecompoundref}}
```
{{kind}} {{name}}
{{#each basecompoundref}}
: {{prot}} {{name}}
{{/each}}
```
{{/if}}

{{briefdescription}}

{{detaileddescription}}

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
{{#each filtered.compounds}}{{cell proto}} | {{cell summary}}
{{/each}}{{#each filtered.members}}{{cell proto}} | {{cell summary}}
{{/each}}

## Members

{{#each filtered.compounds}}
#### {{title proto}} {{anchor refid}}

{{briefdescription}}

{{detaileddescription}}
{{/each}}

{{#each filtered.members}}
#### {{title proto}} {{anchor refid}}

{{#if enumvalue}}
Values | Descriptions
--------------------------------|---------------------------------------------
{{#each enumvalue}}{{cell name}} | {{cell summary}}
{{/each}}
{{/if}}

{{briefdescription}}

{{detaileddescription}}

{{/each}}
27 changes: 27 additions & 0 deletions templates/java/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Summary

Members | Descriptions
--------------------------------|---------------------------------------------
{{#each filtered.members}}{{cell proto}} | {{cell summary}}
{{/each}}{{#each filtered.compounds}}{{cell proto}} | {{cell summary}}
{{/each}}

{{#if filtered.members}}
## Members

{{#each filtered.members}}
#### {{title proto}} {{anchor refid}}

{{briefdescription}}

{{#if enumvalue}}
Values | Descriptions
--------------------------------|---------------------------------------------
{{#each enumvalue}}{{cell name}} | {{cell summary}}
{{/each}}
{{/if}}

{{detaileddescription}}

{{/each}}
{{/if}}
33 changes: 33 additions & 0 deletions templates/java/namespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# {{kind}} `{{name}}` {{anchor refid}}

{{briefdescription}}

{{detaileddescription}}

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
{{#each filtered.members}}{{cell proto}} | {{cell summary}}
{{/each}}{{#each filtered.compounds}}{{cell proto}} | {{cell summary}}
{{/each}}

{{#if filtered.members}}
## Members

{{#each filtered.members}}
#### {{title proto}} {{anchor refid}}

{{#if enumvalue}}
Values | Descriptions
--------------------------------|---------------------------------------------
{{#each enumvalue}}{{cell name}} | {{cell summary}}
{{/each}}
{{/if}}

{{briefdescription}}

{{detaileddescription}}

{{/each}}
{{/if}}
34 changes: 34 additions & 0 deletions templates/java/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# {{kind}} `{{name}}` {{anchor refid}}

{{briefdescription}}

{{detaileddescription}}

{{#if filtered.members}}

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
{{#each filtered.members}}{{cell proto}} | {{cell summary}}
{{/each}}{{#each filtered.compounds}}{{cell proto}} | {{cell summary}}
{{/each}}

## Members

{{#each filtered.members}}
#### {{title proto}} {{anchor refid}}

{{#if enumvalue}}
Values | Descriptions
--------------------------------|---------------------------------------------
{{#each enumvalue}}{{cell name}} | {{cell summary}}
{{/each}}
{{/if}}

{{briefdescription}}

{{detaileddescription}}

{{/each}}
{{/if}}
Loading