()
| 162 | // the definition of what constitutes an R Markdown site differs |
| 163 | // depending on the type of R Markdown site (i.e., "simple" vs. blogdown sites) |
| 164 | private async findSiteParam(): Promise<string | undefined> { |
| 165 | const wad = vscode.window.activeTextEditor?.document.uri.fsPath; |
| 166 | if (!wad) { |
| 167 | return; |
| 168 | } |
| 169 | const rootFolder = vscode.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? path.dirname(wad); |
| 170 | const indexFile = (await vscode.workspace.findFiles(new vscode.RelativePattern(rootFolder, 'index.{Rmd,rmd, md}'), null, 1))?.[0]; |
| 171 | const siteRoot = path.join(path.dirname(wad), '_site.yml'); |
| 172 | |
| 173 | // 'Simple' R Markdown websites require all docs to be in the root folder |
| 174 | if (fs.existsSync(siteRoot)) { |
| 175 | return 'rmarkdown::render_site'; |
| 176 | // Other generators may allow for docs in subdirs |
| 177 | } else if (indexFile) { |
| 178 | const indexData = this.getYamlFrontmatter(indexFile.fsPath); |
| 179 | if (indexData?.['site']) { |
| 180 | return indexData['site']; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return undefined; |
| 185 | } |
| 186 | |
| 187 | // readme files should not be knitted via render_site |
| 188 | private isREADME(docPath: string) { |
no test coverage detected