예제 #1
0
  private void runSphinx() throws MavenReportException {
    PySystemState engineSys = new PySystemState();

    engineSys.path.append(Py.newString(sphinxSourceDirectory.getAbsolutePath()));
    Py.setSystemState(engineSys);

    ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");

    if (verbose) {
      getLog()
          .info(
              "Running sphinx on "
                  + sourceDirectory.getAbsolutePath()
                  + ", output will be placed in "
                  + outputDirectory.getAbsolutePath());
    }

    List<String> args = new ArrayList<String>();

    if (verbose) {
      args.add("-v");
    } else {
      args.add("-Q");
    }
    if (warningsAsErrors) {
      args.add("-W");
    }
    if (force) {
      args.add("-a");
      args.add("-E");
    }
    if (builder != null) {
      args.add("-b");
      args.add(builder);
    }
    if ((tags != null) && !tags.isEmpty()) {
      for (String tag : tags) {
        args.add("-t");
        args.add(tag);
      }
    }
    args.add("-n");
    args.add(sourceDirectory.getAbsolutePath());
    args.add(outputDirectory.getAbsolutePath());

    engine.put("args", args.toArray(new String[args.size()]));
    try {
      engine.eval("import sphinx; sphinx.main(args)");
    } catch (ScriptException ex) {
      throw new MavenReportException("Could not generate documentation", ex);
    }
  }
예제 #2
0
파일: ProxyMaker.java 프로젝트: int3/jython
 /**
  * Retrieves <code>name</code> from the PyObject in <code>proxy</code> if it's defined in Python.
  * This is a specialized helper function for internal PyProxy use.
  */
 public static PyObject findPython(PyProxy proxy, String name) {
   PyObject o = proxy._getPyInstance();
   if (o == null) {
     proxy.__initProxy__(new Object[0]);
     o = proxy._getPyInstance();
   }
   PyObject ret = o.__findattr__(name);
   if (ret instanceof PyMethod) {
     PyMethod meth = ((PyMethod) ret);
     if (meth.__func__ instanceof PyReflectedFunction) {
       PyReflectedFunction func = (PyReflectedFunction) meth.__func__;
       if (func.nargs > 0 && proxy.getClass() == func.argslist[0].declaringClass) {
         // This function is the default return for the proxy type if the Python instance
         // hasn't returned something of its own from __findattr__, so do the standard
         // Java call on this
         return null;
       }
     }
   }
   Py.setSystemState(proxy._getPySystemState());
   return ret;
 }
예제 #3
0
 protected void setState() {
   Py.setSystemState(systemState);
 }