Hi There,
I need to generate API documentation from vRO workflows and actions, so far i found that we can generate for workflows only but i need for actions too
Is there any way to generate API Document from action?
Thanks & Regards,
Laxminarsaiah Ragi
Hi,
Currently, the only options are to generate documentation for either a single workflow or for a workflow category (that includes all workflows in the category).
It should be relatively easy to add support for documentation generation for scripting actions. Feel free to open support request.
Hi Ilian Iliev,
I just wanted to know how a workflow is being exported as PDF when we select "Generate Documentation" option. somewhere some script must be invoked right.
just curious to know that piece of code. so that i can try to apply that logic on the actions for now.
Thank you
-------------
Laxmi
Hi,
There is a vRO plug-in (Workflow Documentation plug-in) that provides integration with a third-party library to generate PDF documentation for workflows. It is not a Javascript scripting code that you can easily extend to generate documentation for actions.
FWWI
I've done this in JS code using HTML templates loaded from vRO resource elements + then writing the HTML pages into new vRO resource elements.
I've attached a sample template for what one looks like + the workflow code is here
function nameMatches(n, arr)
{
for each(var s in arr)
{
if(n.indexOf(s) > -1)
{
return true;
}
}
return false;
}
function replaceToken(content, tok, value)
{
// clone this here?
var ret = content;
if(content.indexOf(tok) > -1)
{
//System.log("replacing " + tok + " with " + value);
ret = ret.replace(tok, value);
}
return ret;
}
// convert parameters into a list of names & type names
function convertParams(paramsArray)
{
var ret = "";
for each(var p in paramsArray)
{
ret = ret + p.name + " : " + p.type + "<br>";
}
return ret;
}
// extract the content of the MimeAttachment in the given resource element
function getMimeContent(resElem)
{
return resElem.getContentAsMimeAttachment().content;
}
// generate the page content
function generatePage(pageTmpl, styleDefs, content, title)
{
var page = getMimeContent(pageTmpl);
page = replaceToken(page, "${embeddedStyleDefs}", getMimeContent(styleDefs));
page = replaceToken(page, "${PageTitle}", title);
page = replaceToken(page, "${bodyContent}", content);
//page = page.replace(/^\s*\n/gm, "");
return page;
}
// generate the section on the index page for the comments & meta info
function generateCommentsSection(tmpl, user, cTxt)
{
var commentsSection = getMimeContent(tmpl);
commentsSection = replaceToken(commentsSection, "${generatedBy}", user);
commentsSection = replaceToken(commentsSection, "${commentText}", cTxt);
commentsSection = replaceToken(commentsSection, "${generatedTimestamp}", System.formatDate(new Date(), "EEE, d MMM yyyy HH:mm:ss"));
return commentsSection;
}
// generate the list of actions for a module
function generateActionList(tmpl, mod)
{
var content = "";
for each(var a in mod.actionDescriptions)
{
var line = getMimeContent(tmpl);
line = replaceToken(line, "${ActionName}", a.name);
line = replaceToken(line, "${ActionPageName}", "./" + mod.name + "." + a.name+".html");
content += (line + "\n");
}
return content;
}
// generates the details of an action
// name, description, script content, params, return type
function generateActionSection(tmpl, act)
{
var content = getMimeContent(tmpl);
content = replaceToken(content, "${ActionName}", act.name);
content = replaceToken(content, "${ActionDescription}", act.description);
content = replaceToken(content, "${ActionContent}", act.script);
content = replaceToken(content, "${ActionParams}", convertParams(act.parameters));
content = replaceToken(content, "${ActionReturnType}", act.returnType);
return content;
}
// generate the section on the index page for a Module and it's child actions
function generateModuleSection(modTmpl, listTmpl, m)
{
var sectionTxt = getMimeContent(modTmpl);
sectionTxt = replaceToken(sectionTxt, "${ModuleName}", m.name);
sectionTxt = replaceToken(sectionTxt, "${ModuleDescription}", m.description);
sectionTxt = replaceToken(sectionTxt, "${ModuleList}", generateActionList(listTmpl, m));
return sectionTxt;
}
function generateActionPage(pageTmpl, styleTmpl, actionTmpl, action)
{
var bodyContent = generateActionSection(actionTmpl, action);
var actionPage = generatePage(pageTmpl, styleTmpl, bodyContent, action.name);
return actionPage;
}
// generate the comments/header section with the meta info
var bodyContent = generateCommentsSection(commentsTemplate, username, comment);
// get all modules available
var allModules = System.getAllModules();
// store generated pages
var actionPages = {};
actionPages.modulePacks = [];
// generate the per-module section with links to child action pages
for each(var module in allModules)
{
// filter on the ones we want to generate docs for
if(nameMatches(module.name, actionMatchNames))
{
bodyContent = bodyContent + generateModuleSection(moduleTemplate, actionListMemberTemplate, module);
modulePack = {};
modulePack.packName = module.name;
modulePack.pageEntries = [];
for each(var moduleAction in module.actionDescriptions)
{
// create a page for each action in the module
var pageEntry = {};
pageEntry.pageContent = generateActionPage(pageTemplate, styleDefsContent, actionPageTemplate, moduleAction);
pageEntry.name = moduleAction.name + ".html";
modulePack.pageEntries.push(pageEntry);
}
actionPages.modulePacks.push(modulePack);
}
}
var indexPage = generatePage(pageTemplate, styleDefsContent, bodyContent, "Action Module Documentation");
System.log(indexPage);
// create the index page as a ResourceElement
System.getModule("com.triangle.util").createResourceElement(outputLocation, "index.html", indexPage, "txt/html");
// now create a page for each module pack entry
for each(var modulePack in actionPages.modulePacks)
{
for each(var actionPage in modulePack.pageEntries)
{
System.getModule("com.triangle.util").createResourceElement(outputLocation, modulePack.packName+"."+actionPage.name, actionPage.pageContent, "txt/html");
}
}
// created resource elements can now be exported to File and viewed in a browser
I was also looking into PDF generation using this approach (possibly by converting HTML --> RTF and then RTF --> PDF... ) But I never completed that as HTML suited my needs here
Anyway, HTH
--EDIT: Syntax highlighting seems to have mucked up my code indentation.... it's still readable, just not pretty anymore