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;
}
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;
}
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();
}
Aggregations