diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a3adf..9ef114a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,4 +46,10 @@ All notable changes to the "rmarkdown" extension will be documented in this file ### Added -- Blogdown: Default author setting \ No newline at end of file +- Blogdown: Default author setting + +## 0.0.8 - 2020-04-16 + +### Added + +- 'Bookdown: Serve Book' command \ No newline at end of file diff --git a/README.md b/README.md index 71bae6f..c4cba65 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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'. @@ -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 diff --git a/package.json b/package.json index 0343d49..2741d36 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -43,7 +43,7 @@ "snippets": [ { "language": "rmarkdown", - "path": "./snippets.json" + "path": "./snippets/snippets.json" } ], "keybindings": [ @@ -104,6 +104,10 @@ { "command": "rmarkdown_vscode.blogdown.NewPost", "title": "Blogdown: New Post" + }, + { + "command": "rmarkdown_vscode.bookdown.serveBook", + "title": "Bookdown: Serve Book" } ], "configuration": [ diff --git a/snippets.json b/snippets/snippets.json similarity index 100% rename from snippets.json rename to snippets/snippets.json diff --git a/src/auto.ts b/src/auto.ts index 2dbc913..fcea79c 100644 --- a/src/auto.ts +++ b/src/auto.ts @@ -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) { @@ -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(); diff --git a/src/blogdown/commands/ServeSite.ts b/src/blogdown/commands/ServeSite.ts index e1b7923..28b99ff 100644 --- a/src/blogdown/commands/ServeSite.ts +++ b/src/blogdown/commands/ServeSite.ts @@ -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); diff --git a/src/bookdown/commands/ServeBook.ts b/src/bookdown/commands/ServeBook.ts new file mode 100644 index 0000000..f1ddd16 --- /dev/null +++ b/src/bookdown/commands/ServeBook.ts @@ -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); + } +}