Package com.atlassian.labs.speakeasy.commonjs.util

Examples of com.atlassian.labs.speakeasy.commonjs.util.JsDoc


            ModuleDescriptor webResourceModuleDescriptor = descriptor.createIndividualModuleDescriptor();

            Element root = createElement("web-resource");
            Element dep = root.addElement("dependency");
            dep.setText(descriptor.getCompleteKey() + "-modules");
            JsDoc jsDoc = modules.getModule(id).getJsDoc();
            addAnnotatedContext(root, jsDoc);
            Element jsTransform = getJsTransformation(root);
            Element trans = jsTransform.addElement("transformer");
            trans.addAttribute("key", "commonjs-module-entry");
            trans.addAttribute("moduleId", id);
View Full Code Here


        {
            Element res = root.addElement("resource");
            res.addAttribute("type", "download");
            res.addAttribute("name", id + ".js");
            res.addAttribute("location", modules.getModulePath(id));
            JsDoc jsDoc = modules.getModule(id).getJsDoc();
            addAnnotatedDependencies(root, descriptor.getPluginKey(), jsDoc);
        }


        for (String dep : resolvedExternalModules)
View Full Code Here

            jsDoc = parseContent(moduleContents, dependencies);
            this.dependencies = ImmutableSet.copyOf(dependencies);
        }
        else if (path.endsWith(".mu"))
        {
            jsDoc = new JsDoc("Mustache template");
            this.dependencies = ImmutableSet.of("speakeasy/mustache");
            final Export export = new Export("render", new JsDoc("Renders the template with the provided context"));
            exports.put("render", export);
        }
        else
        {
            throw new IllegalArgumentException("Invalid module:" + id + " of path:" + path);
View Full Code Here

        notNull(jsDoc);
    }

    private JsDoc parseContent(String moduleContents, final Set<String> dependencies)
    {
        final AtomicReference<JsDoc> jsDoc = new AtomicReference<JsDoc>(new JsDoc(""));
        CompilerEnvirons env = new CompilerEnvirons();
        env.setRecordingComments(true);
        env.setRecordingLocalJsDocComments(true);
        Parser parser = new Parser(env, new ErrorReporter()
        {

            public void warning(String message, String sourceName, int line, String lineSource, int lineOffset)
            {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            public void error(String message, String sourceName, int line, String lineSource, int lineOffset)
            {
                log.warn("Error parsing module " + id + ":\n" +
                        "  Message: " + message + "\n" +
                        "  Line:    " + line + "\n" +
                        "  Line Src:" + lineSource + "\n" +
                        "  Column:  " + lineOffset);
                throw new RuntimeException("Error parsing module '" + id + "' on line " + line + ": " + message);
            }

            public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset)
            {
                return null//To change body of implemented methods use File | Settings | File Templates.
            }
        });
        try
        {
            final AstRoot root = parser.parse(new StringReader(moduleContents), path, 1);
            if (root.getComments() != null && !root.getComments().isEmpty())
            {
                final String rawHeaderDocs = root.getComments().first().getValue();
                jsDoc.set(JsDocParser.parse(getId(), rawHeaderDocs));
            }

            root.visitAll(new NodeVisitor()
            {
                public boolean visit(AstNode node)
                {
                    try
                    {
                        if (node.getType() == Token.ASSIGN)
                        {
                            Assignment assignment = (Assignment) node;
                            if (assignment.getLeft().getType() == Token.GETPROP)
                            {
                                PropertyGet left = (PropertyGet)assignment.getLeft();
                                if (left.getLeft() instanceof Name && ((Name)left.getLeft()).getIdentifier().equals("exports"))
                                {
                                    String exportName = left.getProperty().getIdentifier();
                                    Export export = new Export(exportName, JsDocParser.parse(getId(), node.getJsDoc()));
                                    if (jsDoc.get().getDescription().length() > 0 && export.getJsDoc().getDescription().equals(jsDoc.get().getDescription()))
                                    {
                                        jsDoc.set(new JsDoc(""));
                                    }
                                    exports.put(exportName, export);
                                }
                            }
                        }
View Full Code Here

TOP

Related Classes of com.atlassian.labs.speakeasy.commonjs.util.JsDoc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.