Search in sources :

Example 1 with ReSTService

use of com.jetbrains.python.ReSTService in project intellij-community by JetBrains.

the class SphinxBaseCommand method setWorkDir.

protected boolean setWorkDir(Module module) {
    final ReSTService service = ReSTService.getInstance(module);
    String workDir = service.getWorkdir();
    if (workDir.isEmpty()) {
        AskForWorkDir dialog = new AskForWorkDir(module.getProject());
        if (!dialog.showAndGet()) {
            return false;
        }
        service.setWorkdir(dialog.getInputFile());
    }
    return true;
}
Also used : ReSTService(com.jetbrains.python.ReSTService)

Example 2 with ReSTService

use of com.jetbrains.python.ReSTService in project intellij-community by JetBrains.

the class SphinxBaseCommand method createCommandLine.

protected GeneralCommandLine createCommandLine(Module module, List<String> params) throws ExecutionException {
    Sdk sdk = PythonSdkType.findPythonSdk(module);
    if (sdk == null) {
        throw new ExecutionException("No sdk specified");
    }
    ReSTService service = ReSTService.getInstance(module);
    String sdkHomePath = sdk.getHomePath();
    GeneralCommandLine cmd = new GeneralCommandLine();
    if (sdkHomePath != null) {
        final String runnerName = "sphinx-quickstart" + (SystemInfo.isWindows ? ".exe" : "");
        String executablePath = PythonSdkType.getExecutablePath(sdkHomePath, runnerName);
        if (executablePath != null) {
            cmd.setExePath(executablePath);
        } else {
            cmd = PythonHelper.LOAD_ENTRY_POINT.newCommandLine(sdkHomePath, Lists.<String>newArrayList());
        }
    }
    cmd.setWorkDirectory(service.getWorkdir().isEmpty() ? module.getProject().getBaseDir().getPath() : service.getWorkdir());
    PythonCommandLineState.createStandardGroups(cmd);
    ParamsGroup scriptParams = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
    assert scriptParams != null;
    if (params != null) {
        for (String p : params) {
            scriptParams.addParameter(p);
        }
    }
    final Map<String, String> env = cmd.getEnvironment();
    setPythonIOEncoding(env, "utf-8");
    setPythonUnbuffered(env);
    if (sdkHomePath != null) {
        resetHomePathChanges(sdkHomePath, env);
    }
    env.put("PYCHARM_EP_DIST", "Sphinx");
    env.put("PYCHARM_EP_NAME", "sphinx-quickstart");
    List<String> pathList = Lists.newArrayList(PythonCommandLineState.getAddedPaths(sdk));
    pathList.addAll(PythonCommandLineState.collectPythonPath(module));
    PythonCommandLineState.initPythonPath(cmd, true, pathList, sdkHomePath);
    PythonSdkType.patchCommandLineForVirtualenv(cmd, sdkHomePath, true);
    BuildoutFacet facet = BuildoutFacet.getInstance(module);
    if (facet != null) {
        facet.patchCommandLineForBuildout(cmd);
    }
    return cmd;
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) BuildoutFacet(com.jetbrains.python.buildout.BuildoutFacet) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ReSTService(com.jetbrains.python.ReSTService) Sdk(com.intellij.openapi.projectRoots.Sdk) ExecutionException(com.intellij.execution.ExecutionException)

Example 3 with ReSTService

use of com.jetbrains.python.ReSTService in project intellij-community by JetBrains.

the class PyIntegratedToolsConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    if (myDocstringFormatComboBox.getSelectedItem() != myDocumentationSettings.getFormat()) {
        DaemonCodeAnalyzer.getInstance(myProject).restart();
    }
    if (analyzeDoctest.isSelected() != myDocumentationSettings.isAnalyzeDoctest()) {
        final List<VirtualFile> files = Lists.newArrayList();
        ProjectRootManager.getInstance(myProject).getFileIndex().iterateContent(new ContentIterator() {

            @Override
            public boolean processFile(VirtualFile fileOrDir) {
                if (!fileOrDir.isDirectory() && PythonFileType.INSTANCE.getDefaultExtension().equals(fileOrDir.getExtension())) {
                    files.add(fileOrDir);
                }
                return true;
            }
        });
        FileContentUtil.reparseFiles(myProject, Lists.newArrayList(files), false);
    }
    myModel.apply();
    myDocumentationSettings.setFormat((DocStringFormat) myDocstringFormatComboBox.getSelectedItem());
    final ReSTService reSTService = ReSTService.getInstance(myModule);
    reSTService.setWorkdir(myWorkDir.getText());
    if (txtIsRst.isSelected() != reSTService.txtIsRst()) {
        reSTService.setTxtIsRst(txtIsRst.isSelected());
        reparseFiles(Collections.singletonList(PlainTextFileType.INSTANCE.getDefaultExtension()));
    }
    myDocumentationSettings.setAnalyzeDoctest(analyzeDoctest.isSelected());
    PyPackageRequirementsSettings.getInstance(myModule).setRequirementsPath(myRequirementsPathField.getText());
    DaemonCodeAnalyzer.getInstance(myProject).restart();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentIterator(com.intellij.openapi.roots.ContentIterator) ReSTService(com.jetbrains.python.ReSTService)

Aggregations

ReSTService (com.jetbrains.python.ReSTService)3 ExecutionException (com.intellij.execution.ExecutionException)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 ParamsGroup (com.intellij.execution.configurations.ParamsGroup)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ContentIterator (com.intellij.openapi.roots.ContentIterator)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 BuildoutFacet (com.jetbrains.python.buildout.BuildoutFacet)1