Esempio n. 1
0
  public static void writePage(String docfile, String relative, String outfile) {
    HDF hdf = DroidDoc.makeHDF();

    /*
    System.out.println("docfile='" + docfile
                        + "' relative='" + relative + "'"
                        + "' outfile='" + outfile + "'");
    */

    String filedata = readFile(docfile);

    // The document is properties up until the line "@jd:body".
    // Any blank lines are ignored.
    int start = -1;
    int lineno = 1;
    Matcher lines = LINE.matcher(filedata);
    String line = null;
    while (lines.find()) {
      line = lines.group(1);
      if (line.length() > 0) {
        if (line.equals("@jd:body")) {
          start = lines.end();
          break;
        }
        Matcher prop = PROP.matcher(line);
        if (prop.matches()) {
          String key = prop.group(1);
          String value = prop.group(2);
          hdf.setValue(key, value);
        } else {
          break;
        }
      }
      lineno++;
    }
    if (start < 0) {
      System.err.println(docfile + ":" + lineno + ": error parsing docfile");
      if (line != null) {
        System.err.println(docfile + ":" + lineno + ":" + line);
      }
      System.exit(1);
    }

    // if they asked to only be for a certain template, maybe skip it
    String fromTemplate = hdf.getValue("template.which", "");
    String fromPage = hdf.getValue("page.onlyfortemplate", "");
    if (!"".equals(fromPage) && !fromTemplate.equals(fromPage)) {
      return;
    }

    // and the actual text after that
    String commentText = filedata.substring(start);

    Comment comment = new Comment(commentText, null, new SourcePositionInfo(docfile, lineno, 1));
    TagInfo[] tags = comment.tags();

    TagInfo.makeHDF(hdf, "root.descr", tags);

    hdf.setValue("commentText", commentText);

    // write the page using the appropriate root template, based on the
    // whichdoc value supplied by build
    String fromWhichmodule = hdf.getValue("android.whichmodule", "");
    if (fromWhichmodule.equals("online-pdk")) {
      // leaving this in just for temporary compatibility with pdk doc
      hdf.setValue("online-pdk", "true");
      // add any conditional login for root template here (such as
      // for custom left nav based on tab etc.
      ClearPage.write(hdf, "docpage.cs", outfile);
    } else {
      if (outfile.indexOf("sdk/") != -1) {
        hdf.setValue("sdk", "true");
        if ((outfile.indexOf("index.html") != -1) || (outfile.indexOf("features.html") != -1)) {
          ClearPage.write(hdf, "sdkpage.cs", outfile);
        } else {
          ClearPage.write(hdf, "docpage.cs", outfile);
        }
      } else if (outfile.indexOf("guide/") != -1) {
        hdf.setValue("guide", "true");
        ClearPage.write(hdf, "docpage.cs", outfile);
      } else if (outfile.indexOf("resources/") != -1) {
        hdf.setValue("resources", "true");
        ClearPage.write(hdf, "docpage.cs", outfile);
      } else {
        ClearPage.write(hdf, "nosidenavpage.cs", outfile);
      }
    }
  } // writePage
Esempio n. 2
0
 @Override
 public void makeHDF(HDF data, String base) {
   data.setValue(base + ".name", parameterName());
   data.setValue(base + ".isTypeParameter", isTypeParameter() ? "1" : "0");
   TagInfo.makeHDF(data, base + ".comment", commentTags());
 }