Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cba0c13
Adds JSDoc for CSS REader
paceaux Oct 23, 2025
8104afd
Adds documentation for logger
paceaux Oct 23, 2025
4e8f5a1
documents outputtter
paceaux Oct 23, 2025
b3e400e
adds code docs for element-search-result
paceaux Oct 24, 2025
1f5657f
adds JSDoc comments for SiteCrawler configuration
paceaux Oct 24, 2025
eba8e0b
adds documentation for page search result
paceaux Oct 27, 2025
b9711e3
adds detailed JSDoc comments for SelectorFinder class and its methods
paceaux Oct 27, 2025
b3ee8b7
documents the CLI functions
paceaux Oct 27, 2025
60e4ea0
documents properties set in constructors and methods
paceaux Jun 2, 2026
da050a6
documents constructor and props set in constructor
paceaux Jun 2, 2026
0a34c33
documents method types and props set in methods
paceaux Jun 2, 2026
1434bb3
documents props set in methods.
paceaux Jun 2, 2026
47101fc
corrects formatting of jsdoc comments
paceaux Jun 4, 2026
d6c6166
adds JSDoc comments for siteSearchResult
paceaux Jun 4, 2026
6740640
Adds missing JSDoc info for class and for methods
paceaux Jun 4, 2026
fff61eb
adds jsdoc for linkset and outputter
paceaux Jun 4, 2026
139dde7
adds JSDoc for timerstart and end. Also corrects doc for returns of m…
paceaux Jun 4, 2026
522146d
corrects description of a property
paceaux Jun 4, 2026
93dadb1
Adds documentation for the constants. Includes where the constants ar…
paceaux Jun 4, 2026
02579ef
remove something that would be evident just from intellisense.
paceaux Jun 4, 2026
f387bef
corrects lint complaint about blank line at end.
paceaux Jun 4, 2026
f78ade0
corrects typo
paceaux Jun 26, 2026
bc4f13c
Adds linting for JSDoc specifically.
paceaux Jul 20, 2026
e30d130
automatically and manually applies JSDoc lint fixes
paceaux Jul 20, 2026
6975457
imports types from other files or node_modules. eliminates all JSDoc …
paceaux Jul 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"browser": false,
"es2022": true
},
"extends": "airbnb-base",
"extends": ["airbnb-base", "plugin:jsdoc/recommended"],
"plugins": ["jsdoc"],
"parserOptions": {
"ecmaVersion": 12
},
Expand All @@ -16,6 +17,7 @@
"afterAll": true
},
"rules": {
"import/extensions": "off"
"import/extensions": "off",
"jsdoc/no-defaults": 0
}
}
42 changes: 42 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ const {
showHtml,
} = argv;

/**
* @typedef {object} SelectorFinderConfig
* @property {string} sitemap - URL for the sitemap or starting page
* @property {boolean} crawl - Whether to treat the URL as an HTML page and crawl from there
* @property {number} limit - How many pages to crawl (0 for unlimited)
* @property {boolean} useExportedSitemap - Whether to use existing sitemap file or force refetch
* @property {string|string[]} selector - CSS selector(s) to search for
* @property {string} outputFileName - Name of the output file
* @property {boolean} takeScreenshots - Whether to take screenshots of matched elements
* @property {boolean} isSpa - Whether the target is a Single Page Application
* @property {string} [cssFile] - Optional path to a CSS file to extract selectors from
* @property {boolean} showElementDetails - Whether to show element details like tagname,
* attributes, innerText
* @property {boolean} showHtml - Whether to show HTML markup for matched elements
* @property {SiteCrawler} [siteCrawler] - Optional SiteCrawler instance (added during processing)
*/
const selectorFinderConfig = {
sitemap,
crawl,
Expand All @@ -128,6 +144,12 @@ const selectorFinderConfig = {
showHtml,
};

/**
* Decides if it's a single selector or an array b/c it's a CSS file
* @async
* @param {SelectorFinderConfig} config - configuration for finding CSS selectors
* @returns {Promise<SelectorFinderConfig>} - a modified config
*/
async function setCSSFileSelectors(config) {
if (config.cssFile) {
try {
Expand All @@ -142,6 +164,19 @@ async function setCSSFileSelectors(config) {
return config;
}

/**
* @typedef SelectorSearchResult
* @property {number} totalPagesSearched - the total number of pages search
* @property {Map<string, object>} pagesWithSelector - a K-V map where K is url and V is page object
*/

/**
* Formats the results based on what the user has asked for
* @param {SelectorSearchResult} result - a search result (defined in selector.finder.js)
* @param {boolean} hasElementDetails - whether the json should show element details
* @param {boolean} hasElementHtml - whether the full HTML should be shown for the element
* @returns {object} page results with or without extra details on results
*/
function getFormattedResult(result, hasElementDetails, hasElementHtml) {
const formattedResult = { ...result };

Expand Down Expand Up @@ -174,6 +209,13 @@ function getFormattedResult(result, hasElementDetails, hasElementHtml) {

return formattedResult;
}

/**
* The CLI; where everything starts
* @async
* @param {SelectorFinderConfig} config - The configuration from command line arguments
* @returns {Promise<void>}
*/
async function main(config) {
const outputter = new Outputter(DEFAULT_OUTPUT_FILE, log);
let mainConfig = { ...config };
Expand Down
Loading
Loading