Skip to content

Commit

Permalink
Revert "copy adjacent files for vignette preview"
Browse files Browse the repository at this point in the history
This reverts commit 47b4707.
  • Loading branch information
jjallaire committed Apr 11, 2014
1 parent 8ebc67a commit 938ac10
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 60 deletions.
9 changes: 0 additions & 9 deletions src/cpp/session/SessionModuleContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,15 +745,6 @@ FilePath tempDir()
return r::session::utils::tempDir();
}

Error copyDirectory(const FilePath& srcDir, const FilePath& targetDir)
{
r::exec::RFunction copy("file.copy");
copy.addParam("from", string_utils::utf8ToSystem(srcDir.absolutePath()));
copy.addParam("to", string_utils::utf8ToSystem(targetDir.absolutePath()));
copy.addParam("recursive", true);
return copy.call();
}

FilePath findProgram(const std::string& name)
{
std::string which;
Expand Down
4 changes: 0 additions & 4 deletions src/cpp/session/include/session/SessionModuleContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ core::FilePath tempFile(const std::string& prefix,

core::FilePath tempDir();

// copy a directory
core::Error copyDirectory(const core::FilePath& srcDir,
const core::FilePath& targetDir);

// find out the location of a binary
core::FilePath findProgram(const std::string& name);

Expand Down
30 changes: 3 additions & 27 deletions src/cpp/session/modules/rmarkdown/SessionRMarkdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,37 +796,13 @@ Error renderRmd(const json::JsonRpcRequest& request,
Error renderRmdSource(const json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
std::string source, file;
Error error = json::readParams(request.params, &source, &file);
std::string source;
Error error = json::readParams(request.params, &source);
if (error)
return error;

// create temp directory
FilePath previewPath = module_context::tempFile("rstudio-", "dir");
error = previewPath.ensureDirectory();
if (error)
{
LOG_ERROR(error);
return error;
}

// if there is a source file then copy it's directory into the
// temp directory (to resolve relative paths)
if (!file.empty())
{
FilePath filePath = module_context::resolveAliasedPath(file);
FilePath srcDir = filePath.parent();
Error error = module_context::copyDirectory(srcDir, previewPath);
if (error)
{
LOG_ERROR(error);
return error;
}
previewPath = previewPath.childPath(srcDir.filename());
}

// create temp file
FilePath rmdTempFile = previewPath.childPath("preview.Rmd");
FilePath rmdTempFile = module_context::tempFile("Preview-", "Rmd");
error = core::writeStringToFile(rmdTempFile, source);
if (error)
return error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,15 @@ public interface Handler extends EventHandler
void onRenderRmdSource(RenderRmdSourceEvent event);
}

public RenderRmdSourceEvent(String source, String file)
public RenderRmdSourceEvent(String source)
{
source_ = source;
file_ = file;
}

public String getSource()
{
return source_;
}

public String getFile()
{
return file_;
}

@Override
public Type<Handler> getAssociatedType()
Expand All @@ -54,7 +48,6 @@ protected void dispatch(Handler handler)
}

private final String source_;
private final String file_;

public static final Type<Handler> TYPE = new Type<Handler>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void renderRmd(String file, int line, String format, String encoding,
ServerRequestCallback<Boolean> requestCallback);

void renderRmdSource(String source,
String file,
ServerRequestCallback<Boolean> requestCallback);

void terminateRenderRmd(ServerRequestCallback<Void> requestCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3273,13 +3273,10 @@ public void renderRmd(String file, int line, String format, String encoding,
}

@Override
public void renderRmdSource(String source, String file,
public void renderRmdSource(String source,
ServerRequestCallback<Boolean> requestCallback)
{
JSONArray params = new JSONArray();
params.set(0, new JSONString(source));
params.set(1, new JSONString(StringUtil.notNull(file)));
sendRequest(RPC_SCOPE, RENDER_RMD_SOURCE, params, requestCallback);
sendRequest(RPC_SCOPE, RENDER_RMD_SOURCE, source, requestCallback);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onRenderRmd(RenderRmdEvent event)
@Override
public void onRenderRmdSource(RenderRmdSourceEvent event)
{
server_.renderRmdSource(event.getSource(), event.getFile(),
server_.renderRmdSource(event.getSource(),
new SimpleRequestCallback<Boolean>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3350,8 +3350,7 @@ void renderRmd()

if (renderSourceOnly)
{
rmarkdownHelper_.renderRMarkdownSource(docDisplay_.getCode(),
docUpdateSentinel_.getPath());
rmarkdownHelper_.renderRMarkdownSource(docDisplay_.getCode());
}

else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,14 @@ public void execute(RMarkdownContext arg)
});
}

public void renderRMarkdownSource(final String source,
final String file)
public void renderRMarkdownSource(final String source)
{
withRMarkdownPackage("Rendering R Markdown documents",
new CommandWithArg<RMarkdownContext>() {
@Override
public void execute(RMarkdownContext arg)
{
eventBus_.fireEvent(new RenderRmdSourceEvent(source, file));
eventBus_.fireEvent(new RenderRmdSourceEvent(source));
}
});
}
Expand Down

0 comments on commit 938ac10

Please sign in to comment.