MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / getKnitCommand

Method getKnitCommand

src/rmarkdown/knit.ts:130–159  ·  view source on GitHub ↗
(yamlParams: IYamlFrontmatter, docPath: string, outputFormat?: string)

Source from the content-addressed store, hash-verified

128 }
129
130 private async getKnitCommand(yamlParams: IYamlFrontmatter, docPath: string, outputFormat?: string): Promise<string | undefined> {
131 let knitCommand: string;
132
133 if (!yamlParams?.['site']) {
134 yamlParams['site'] = await this.findSiteParam();
135 }
136
137 // precedence:
138 // knit > site > configuration
139 if (yamlParams?.['knit']) {
140 const knitParam = yamlParams['knit'].trim();
141 knitCommand = outputFormat ?
142 `${knitParam}(${docPath}, output_format = '${outputFormat}')` :
143 `${knitParam}(${docPath})`;
144 } else if (!this.isREADME(docPath) && yamlParams?.['site']) {
145 knitCommand = outputFormat ?
146 `rmarkdown::render_site(${docPath}, output_format = '${outputFormat}')` :
147 `rmarkdown::render_site(${docPath})`;
148 } else {
149 const cmd = util.config().get<string>('rmarkdown.knit.command');
150 if (!cmd) {
151 return;
152 }
153 knitCommand = outputFormat ?
154 `${cmd}(${docPath}, output_format = '${outputFormat}')` :
155 `${cmd}(${docPath})`;
156 }
157
158 return knitCommand.replace(/['"]/g, '\'');
159 }
160
161 // check if the workspace of the document is a R Markdown site.
162 // the definition of what constitutes an R Markdown site differs

Callers 1

renderDocumentMethod · 0.95

Calls 3

findSiteParamMethod · 0.95
isREADMEMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected