Skip to content
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

[DX-1717]Add taskfile with md:list and md:fmt targets #4321

Closed
wants to merge 4 commits into from

Conversation

titpetric
Copy link
Contributor

@titpetric titpetric commented Mar 22, 2024

This pull requests contains a draft Taskfile.yml. You'll need some software installed:

The following taskfile targets are available:

task: Available tasks for this project:
* md:fmt:        Run mdox fmt on changed .md files on PR
* md:list:       List changed .md files on PR

A few issues have been filed upstream against mdox, some have work arounds when running task md:fmt:

Additionally, md:list also reformats code blocks with a dot prefix (e.g. .js becomes js). This issue is more of a hugo validation issue. For the extremely wrong variants mdox does report issues when scanning.

In order for this to be usable:

  • your checkout should have up to date master branch, and the PR branch
  • run task md:fmt and it will auto-correct any changes made in the PR

It's absolutely required to keep master in sync with the PR branch on local. If the PR gets rebased, and you don't update your local checkout of the master branch, additional files will be reformatted.

Note: the tool also nicely reformats markdown tables, however more testing is needed to see if some unwanted behaviour occurs for the existing docs. Tested via #4186 ;

To use this for testing on PRs (before any merges are considered), fetch the file inside the root of the repository:

wget https://raw.githubusercontent.com/TykTechnologies/tyk-docs/8fcd9f72cf70ad0b5a771d30457144d2b4b3a15d/Taskfile.yml

This lets you run task md:list to inspect which changes on a PR would be analyzed, and task md:fmt to run the formatters.

Copy link
Contributor

@dcs3spp dcs3spp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!! Is the usage before running this:

git checkout master
git pull origin master
git checkout pr-branch
git pull origin pr-branch

task md:list
task md:fmt

Could it be used in a client side commit hook using something like pre-commit or lint-staged?

@titpetric
Copy link
Contributor Author

@dcs3spp pretty much; you need a wget to fetch the taskfile on local, as this isn't merged to the main branch yet.

Running it in client side hooks would be possible, needs testing, and standardizing on something like lefthook.

@saswatamcode
Copy link

Thanks for opening the issues on mdox, will take a look :)

@titpetric titpetric force-pushed the test/enforce-markdown-formatting branch from 8fcd9f7 to 5aa4915 Compare June 10, 2024 20:15
@yurisasuke yurisasuke changed the title Add taskfile with md:list and md:fmt targets [DX-1717]Add taskfile with md:list and md:fmt targets Oct 15, 2024
@yurisasuke
Copy link
Member

closed in favour of prettier .We will revisti if needed

https://tyktech.atlassian.net/browse/DX-1717

@yurisasuke yurisasuke closed this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants