New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
64232 cleanup scripts #148
Conversation
…f parse with yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very neat! Are some of these going to be made available through a "Format on Save" type option?
* and cleans up Yaml Metadata values that have single array items | ||
* then converts the array to single item. | ||
*/ | ||
function handleSingValuedMetadata() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sing ->Single
return data.replace(regex, `${variable}: ${value}`) | ||
} | ||
catch (error) { | ||
console.error('Error occurred:', error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure it does, but when the error is logged, does it also log the line number?
} | ||
|
||
switch (selection.label.toLowerCase()) { | ||
case "single-valued metadata": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we using typescript 2? If so we could use the readonly modifier and start moving strings like this to immutable constants.
data = data.replace(technetRegex, "https://technet.microsoft.com") | ||
let docsRegexLang = new RegExp(/https:\/\/docs.microsoft.com\/[A-Za-z]{2}-[A-Za-z]{2}\//g) | ||
data = data.replace(docsRegexLang, "https://docs.microsoft.com/") | ||
let azureRegexLang = new RegExp(/https:\/\/azure.microsoft.com\/[A-Za-z]{2}-[A-Za-z]{2}\//g) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one time i've had to "undo" this is when it was embedded in sample JSON response from the translation API. Probably not worth coding around that though
docs-markdown/package.json
Outdated
{ | ||
"command": "applyCleanup", | ||
"group": "Docs", | ||
"when": "vscode.extensions.getExtension('docsmsft.docs-article-templates').active" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can change this to "resourceLangId == markdown" so it doesn't have a dependency on the templates extension.
items.push({ | ||
description: "", | ||
label: "$(tasklist) Cleanup...", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved out of the template extension check into the core quickpick menu.
Feedback - Do not merge
Thank you for the suggestion and that is an excellent Idea. I will see if we can make that happen. It would be far less intrusive to keep a markdown linter watching vs running a long process to fix everything all at once. |
@bharney-msft do you want me to file a separate issue? |
@nschonni Sounds good, please do file another issue. I like that idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Cleanup... is accessible via the markdown extension (Alt + M) and allows the user to update metadata for each file in the working root directory/ repo. Cleanup... does 4 main things:
The scripts also touch each file in the repo and replace values. So the total time the scripts take to run/complete will vary based on the size of the repo. Any where from a few seconds to 4 minutes for the sql-docs and azure repos.