Skip to content

Commit

Permalink
v0.0.8 bookdown serve book
Browse files Browse the repository at this point in the history
  • Loading branch information
TianyiShi2001 committed Apr 15, 2020
1 parent acfb4cf commit 128413b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ All notable changes to the "rmarkdown" extension will be documented in this file

### Added

- Blogdown: Default author setting
- Blogdown: Default author setting

## 0.0.8 - 2020-04-16

### Added

- 'Bookdown: Serve Book' command
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ Additionally, it aims to provide some helper functions for Bookdown and Blogdown
- [Snippets](#snippets)
- [Cross-referencing](#cross-referencing)
- [Chunks](#chunks)
- [Bookdown-Specific Features](#bookdown-specific-features)
- [Serve Book](#serve-book)
- [Serve Site](#serve-site)
- [Blogdown-Specific Features](#blogdown-specific-features)
- [New Post](#new-post)
- [Serve Site](#serve-site)
- [Serve Site](#serve-site-1)
- [Other Markdown Features](#other-markdown-features)
- [Syntax Highlighting](#syntax-highlighting)
- [Keyboard Shortcuts](#keyboard-shortcuts-1)
Expand All @@ -28,7 +31,7 @@ Additionally, it aims to provide some helper functions for Bookdown and Blogdown

# Video Demos

_If you prefer reading text, jump to [RMarkdown-Specific Features from here](#user-content-rmarkdown-specific-features)._
_If you prefer reading text, jump to [RMarkdown-Specific Features](#user-content-rmarkdown-specific-features), [Blogdown-Specific Features](#blogdown-specific-features), [Bookdown-Specific Features](#bookdown-specific-features), or [Other Markdown Features](#other-markdown-features)._

## Code Chunk

Expand Down Expand Up @@ -75,9 +78,22 @@ Use `Ctrl/Cmd+Shift+K` to knit the document with options specified in the YAML h
`\code`: insert a code chunk
`\fig`: insert a chunk using `knitr::include_graphics()` to include an image; hit tabs to conviniently fill out label, `fig.cap` and `out.width`.

# Bookdown-Specific Features

Before you can use blogdown-specific features, you need to first open the directory of your **bookdown** project. The easiest way is to use RStudio's 'New Project'.

## Serve Book

## Serve Site

1. In the command palette (`Ctrl/Cmd+Shift+P`), search for `serve book`
2. Execute `Blogdown: Serve Site`
3. Click the link in the output to view your book
4. ~~You are redirected to your new site (not implemented yet)!~~

# Blogdown-Specific Features

Before you can use blogdown-specific features, you need to first open the directory of your **blogdown** project.
Before you can use blogdown-specific features, you need to first open the directory of your **blogdown** project. The easiest way is to use RStudio's 'New Project'.

<!-- that contains at least an `archetype/` directory with at least one archetype file, and an `content/` directory with at least one subdirectory. -->

Expand All @@ -94,7 +110,8 @@ Before you can use blogdown-specific features, you need to first open the direct

1. In the command palette (`Ctrl/Cmd+Shift+P`), search for `serve site`
2. Execute `Blogdown: Serve Site`
3. ~~You are redirected to your new site (not implemented yet)!~~
3. Click the link in the output to view your blog
4. ~~You are redirected to your new site (not implemented yet)!~~

# Other Markdown Features

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"type": "git",
"url": "https://github.com/TianyiShi2001/rmarkdown-vscode.git"
},
"version": "0.0.7",
"version": "0.0.8",
"engines": {
"vscode": "^1.44.0"
},
Expand Down Expand Up @@ -43,7 +43,7 @@
"snippets": [
{
"language": "rmarkdown",
"path": "./snippets.json"
"path": "./snippets/snippets.json"
}
],
"keybindings": [
Expand Down Expand Up @@ -104,6 +104,10 @@
{
"command": "rmarkdown_vscode.blogdown.NewPost",
"title": "Blogdown: New Post"
},
{
"command": "rmarkdown_vscode.bookdown.serveBook",
"title": "Bookdown: Serve Book"
}
],
"configuration": [
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/auto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from "vscode";
import { Knit } from "./rmarkdown-core/commands/Knit";
import { ServeBook } from "./bookdown/commands/ServeBook";
import { ServeSite } from "./blogdown/commands/ServeSite";
import { NewPost } from "./blogdown/commands/NewPost";
export function loadCommands(context: vscode.ExtensionContext) {
Expand All @@ -8,6 +9,11 @@ export function loadCommands(context: vscode.ExtensionContext) {
new Knit().run();
})
);
context.subscriptions.push(
vscode.commands.registerCommand("rmarkdown_vscode.bookdown.serveBook", () => {
new ServeBook().run();
})
);
context.subscriptions.push(
vscode.commands.registerCommand("rmarkdown_vscode.blogdown.ServeSite", () => {
new ServeSite().run();
Expand Down
1 change: 0 additions & 1 deletion src/blogdown/commands/ServeSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class ServeSite extends BaseCommand {
this._outputChannel = vscode.window.createOutputChannel("Blogdown");
}
async run() {
console.log("trying to serve");
let p = spawn(Rscript(Rcall("blogdown::serve_site")), { cwd: vscode.workspace.workspaceFolders![0].uri.path, shell: true });
console.log(p);
verbatimOutput(p, this._outputChannel as vscode.OutputChannel);
Expand Down
19 changes: 19 additions & 0 deletions src/bookdown/commands/ServeBook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// @ts-nocheck
import { Rcall, Rscript } from "r-helper";
import * as vscode from "vscode";
import { BaseCommand } from "../../common/BaseCommand";
import { verbatimOutput } from "../../utils/verbatimOutput";
import { spawn } from "child_process";

// __title__ = "Bookdown: Serve Book";
export class ServeBook extends BaseCommand {
private _outputChannel: vscode.OutputChannel | undefined;
init() {
this._outputChannel = vscode.window.createOutputChannel("Bookdown");
}
async run() {
let p = spawn(Rscript(Rcall("bookdown::serve_book()")), { cwd: vscode.workspace.workspaceFolders![0].uri.path, shell: true });
console.log(p);
verbatimOutput(p, this._outputChannel as vscode.OutputChannel);
}
}

0 comments on commit 128413b

Please sign in to comment.