Skip to content

Commit 0c7e057

Browse files
committed
feat: add custom output file naming option and demo GIF
1 parent e2df127 commit 0c7e057

13 files changed

+69
-38
lines changed

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ vsc-extension-quickstart.md
1313
images/**
1414
node_modules/**
1515
changes.txt
16+
media/demo.gif
1617

1718
# Keep only essential Puppeteer files
1819
!node_modules/puppeteer-core/lib/cjs/**

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [1.4.1] - 2024-11-27
4+
5+
### Added
6+
- Custom output file naming option in UI
7+
- Added demo GIF to README for better feature visualization
8+
39
## [1.3.0] - 2024-11-24
410

511
### Added

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# Docs Miner VSCode Extension
1+
# Docs Miner
22

3-
This extension allows you to generate markdown documentation from web pages and GitHub repositories using either the Jina AI Reader API or a browser-based method.
3+
A VSCode extension that generates markdown documentation from web pages and GitHub repositories.
4+
5+
<p align="center">
6+
<img src="https://raw.githubusercontent.com/3choff/docs-miner/main/media/demo.gif" width="800" alt="Demo">
7+
</p>
48

59
If you find Docs Miner useful, please consider leaving a star ⭐ on github repository or buying me a [coffee](https://ko-fi.com/3choff) to keep me motivated to work on this project.
610

@@ -25,8 +29,7 @@ If you find Docs Miner useful, please consider leaving a star ⭐ on github repo
2529
2. Enter the URL you want to generate documentation from:
2630
- For websites: any web URL (e.g., https://example.com)
2731
- For GitHub: repository URL (e.g., https://github.com/username/repo) or specific directory (e.g., https://github.com/username/repo/tree/main/docs)
28-
3. Specify the output folder for the generated documentation
29-
4. Adjust the crawling depth using the slider:
32+
3. Adjust the crawling depth using the slider:
3033
- For websites:
3134
- Depth 1: Only the entered page
3235
- Depth 2: The entered page and links at the same directory level
@@ -39,9 +42,11 @@ If you find Docs Miner useful, please consider leaving a star ⭐ on github repo
3942
- Depth 3: Root + two directory levels
4043
- Depth 4: Root + three directory levels
4144
- Depth 5: Root + four directory levels
42-
5. Click "Start Crawling" to begin
43-
6. Monitor the progress in real-time
44-
7. Use the "Stop Crawling" button if you want to end the process early
45+
4. Specify the file name for the generated documentation. If not specified, the URL will be used instead.
46+
5. Specify the output folder for the generated documentation. If not specified, the current workspace folder will be used.
47+
6. Click "Start Crawling" to begin
48+
7. Monitor the progress in real-time
49+
8. Use the "Stop Crawling" button if you want to end the process early
4550

4651
The markdown file will be automatically created in your specified output folder and opened for viewing.
4752

@@ -100,3 +105,10 @@ Choose one of the following installation methods:
100105
## Author
101106
- [3choff](https://github.com/3choff)
102107

108+
## Contributing
109+
Feedback and contributions are welcome. If you encounter any issues or have suggestions for improvements, please create a new [issue](https://github.com/3choff/docs-miner/issues) on the GitHub repository.
110+
111+
If you'd like to contribute to the development of the extension, feel free to submit a pull request with your changes.
112+
113+
## License
114+
This extension is licensed under the [MIT License](https://github.com/3choff/docs-miner/blob/main/LICENSE).

media/demo.gif

3.08 MB
Loading

media/webview/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
<div class="section-container">
2929
<div class="section-label">File Settings</div>
3030
<div class="settings">
31-
<label class="checkbox-container">
31+
<label class="checkbox-container">
3232
<input type="checkbox" id="autoOpenFile" />
3333
<span class="checkbox-label">Auto-open the output file</span>
3434
</label>
35+
<div class="file-input">
36+
<input type="text" id="outputFileName" placeholder="File name (optional)" />
37+
</div>
3538
<div class="folder-input">
3639
<input type="text" id="outputFolder" placeholder="Output folder (optional)" />
3740
</div>

media/webview/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const ELEMENTS = {
99
status: document.getElementById('status'),
1010
autoOpenFile: document.getElementById('autoOpenFile'),
1111
outputFolder: document.getElementById('outputFolder'),
12-
crawlerMethod: document.getElementById('crawlerMethod')
12+
crawlerMethod: document.getElementById('crawlerMethod'),
13+
outputFileName: document.getElementById('outputFileName')
1314
};
1415

1516
const DEPTH_DESCRIPTIONS = {
@@ -84,6 +85,7 @@ ELEMENTS.startButton.addEventListener('click', () => {
8485
url,
8586
depth: parseInt(ELEMENTS.depthSlider.value),
8687
outputFolder: ELEMENTS.outputFolder.value.trim(),
88+
outputFileName: ELEMENTS.outputFileName.value.trim(),
8789
method: ELEMENTS.crawlerMethod.value
8890
});
8991
});

media/webview/styles.css

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ button:disabled {
174174
height: 80px;
175175
display: flex;
176176
align-items: center;
177+
white-space: pre-line;
177178
}
178179

179180
.error {
@@ -230,16 +231,9 @@ input[type="checkbox"]:checked::after {
230231
transform: rotate(45deg);
231232
}
232233

233-
.folder-input {
234-
margin-top: 10px;
235-
}
236-
237-
.folder-input input {
234+
.folder-input input, .file-input input {
238235
width: 100%;
239236
padding: 5px;
240-
border: 1px solid var(--vscode-input-border);
241-
background: var(--vscode-input-background);
242-
color: var(--vscode-input-foreground);
243237
}
244238

245239
.feedback {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "docs-miner",
33
"displayName": "Docs Miner",
44
"description": "Generate markdown documentation from web pages and GitHub repositories",
5-
"version": "1.3.0",
5+
"version": "1.4.1",
66
"publisher": "3choff",
77
"icon": "media/icon.png",
88
"repository": {
@@ -13,6 +13,9 @@
1313
"vscode": "^1.80.0"
1414
},
1515
"categories": [
16+
"Education",
17+
"Programming Languages",
18+
"Snippets",
1619
"Other"
1720
],
1821
"activationEvents": [

src/ViewProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ export class ViewProvider implements vscode.WebviewViewProvider {
5050
url: data.url,
5151
depth: data.depth,
5252
method: data.method,
53-
outputFolder: data.outputFolder
53+
outputFolder: data.outputFolder,
54+
outputFileName: data.outputFileName
5455
};
5556

5657
try {
57-
const outputPath = this.fileService.createOutputPath(options.url, options.outputFolder);
58+
const outputPath = this.fileService.createOutputPath(options.url, options.outputFolder, options.outputFileName);
5859
await this.crawlerService.crawl(options, webviewView.webview);
5960
} catch (error) {
6061
const errorMessage = error instanceof Error ? error.message : String(error);

src/services/FileService.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class FileService implements IFileService {
2424
}
2525
}
2626

27-
public createOutputPath(baseUrl: string, outputFolder?: string): string {
27+
public createOutputPath(baseUrl: string, outputFolder?: string, outputFileName?: string): string {
2828
let outputPath = this.workspaceFolder;
2929
if (outputFolder) {
3030
outputPath = path.join(this.workspaceFolder, outputFolder);
@@ -33,19 +33,24 @@ export class FileService implements IFileService {
3333
}
3434
}
3535

36-
const urlParts = new URL(baseUrl);
37-
let urlPath = urlParts.pathname.replace(/\//g, '-');
38-
urlPath = urlPath.replace(/^-|-$/g, '');
39-
if (urlPath === '') urlPath = 'home';
40-
41-
const queryString = urlParts.search.replace(/[?&]/g, '-').replace(/[=]/g, '-');
42-
const sanitizedQuery = queryString ? `-${queryString.replace(/^-|-$/g, '')}` : '';
43-
44-
const fileName = `${urlParts.hostname}${urlPath}${sanitizedQuery}-docs.md`
45-
.toLowerCase()
46-
.replace(/[^a-z0-9\-\.]/g, '-')
47-
.replace(/-+/g, '-')
48-
.substring(0, 255);
36+
let fileName: string;
37+
if (outputFileName) {
38+
fileName = outputFileName.endsWith('.md') ? outputFileName : `${outputFileName}.md`;
39+
} else {
40+
const urlParts = new URL(baseUrl);
41+
let urlPath = urlParts.pathname.replace(/\//g, '-');
42+
urlPath = urlPath.replace(/^-|-$/g, '');
43+
if (urlPath === '') urlPath = 'home';
44+
45+
const queryString = urlParts.search.replace(/[?&]/g, '-').replace(/[=]/g, '-');
46+
const sanitizedQuery = queryString ? `-${queryString.replace(/^-|-$/g, '')}` : '';
47+
48+
fileName = `${urlParts.hostname}${urlPath}${sanitizedQuery}.md`
49+
.toLowerCase()
50+
.replace(/[^a-z0-9\-\.]/g, '-')
51+
.replace(/-+/g, '-')
52+
.substring(0, 255);
53+
}
4954

5055
this.outputFile = path.join(outputPath, fileName);
5156
return this.outputFile;

src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface CrawlOptions {
55
depth: number;
66
method: 'api' | 'browser';
77
outputFolder?: string;
8+
outputFileName?: string;
89
}
910

1011
export interface CrawlStats {
@@ -35,6 +36,6 @@ export interface IContentProcessor {
3536

3637
export interface IFileService {
3738
saveContent(content: string, append?: boolean): Promise<void>;
38-
createOutputPath(baseUrl: string, outputFolder?: string): string;
39+
createOutputPath(baseUrl: string, outputFolder?: string, outputFileName?: string): string;
3940
getOutputFile(): string | undefined;
4041
}

webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ module.exports = {
3939
patterns: [
4040
{
4141
from: 'media',
42-
to: 'media'
42+
to: 'media',
43+
globOptions: {
44+
ignore: ['**/*.gif']
45+
}
4346
}
4447
]
4548
})

0 commit comments

Comments
 (0)