(fromCran: boolean = false)
| 241 | } |
| 242 | |
| 243 | public async getPackages(fromCran: boolean = false): Promise<Package[]|undefined> { |
| 244 | let packages: Package[]|undefined; |
| 245 | this.pullFavoriteNames(); |
| 246 | if(fromCran){ |
| 247 | // Use a placeholder, since multiple different urls are attempted |
| 248 | const CRAN_PATH_PLACEHOLDER = 'CRAN_PATH_PLACEHOLDER'; |
| 249 | |
| 250 | packages = this.getCachedIndexFile(CRAN_PATH_PLACEHOLDER); |
| 251 | if(!packages?.length){ |
| 252 | const cranUrl = await getCranUrl('', this.cwd); |
| 253 | packages = await getPackagesFromCran(cranUrl); |
| 254 | await this.updateCachedIndexFile(CRAN_PATH_PLACEHOLDER, packages); |
| 255 | } |
| 256 | } else{ |
| 257 | packages = await this.getParsedIndexFile(`/doc/html/packages.html`); |
| 258 | if(!packages?.length){ |
| 259 | void vscode.window.showErrorMessage('Help provider not available!'); |
| 260 | } |
| 261 | } |
| 262 | if(packages){ |
| 263 | for(const pkg of packages){ |
| 264 | pkg.isFavorite = this.favoriteNames.has(pkg.name); |
| 265 | pkg.helpPath = ( |
| 266 | pkg.name === 'doc' ? |
| 267 | '/doc/html/packages.html' : |
| 268 | `/library/${pkg.name}/html/00Index.html` |
| 269 | ); |
| 270 | } |
| 271 | } |
| 272 | return packages; |
| 273 | } |
| 274 | |
| 275 | |
| 276 | // parses a package's index file to produce a list of help topics |
no test coverage detected