Markdown code blocks are reflowed
[tool.poetry.dependencies]
...
pytest-timeout = "*"
...
turns into
[tool.poetry.dependencies] ... pytest-timeout = "\*" ...
amp==1.1.4
async_solipsism==0.3
beautifulsoup4==4.11.1
botocore==1.24.37
cvxopt==1.3.0
cvxpy==1.2.0
dill==0.3.4
environs==9.5.0
...
turns into
amp==1.1.4 async_solipsism==0.3 beautifulsoup4==4.11.1 botocore==1.24.37
cvxopt==1.3.0 cvxpy==1.2.0 dill==0.3.4 environs==9.5.0 ...
See docs/work_tools/all.devops_docker.how_to_guide.md after linting
I would
- Understand which steps is responsible for this
- Check on Internet if there is a way to disable this unwanted behavior
- If there is no way to do it, we can add a step to automatically revert those changes (it shouldn't be too difficult)
@sandeepthalapanane this is a Linter bug fix issue. Some useful links for debugging Linter:
- Entrypoint of the
i lintcommand - Main Linter script that calls all the steps
- Linter dev doc
The usual flow is
- Create unit tests to reproduce the problem (the general Linter test file is
linters/test/test_amp_dev_scripts.pyalthough it would be best to put the unit tests in the test file for the specific Linter step that's causing the problem) - Fix the bug
- Confirm with unit tests from step (1) that the problem is fixed
The issue is because of the Prettier library. The Prettier is not treating the block as fenced.
One solution is we can skip Prettier formatting for specific code blocks by adding a <!-- prettier-ignore --> comment immediately above the markdown block. For ref, see the official Prettier docs here:
https://prettier.io/docs/en/ignore.html
Example:
<!-- prettier-ignore -->
```markdown
[tool.poetry.dependencies]
...
pytest-timeout = "*"
...
This solution is fine if nothing else works, but just wondering, do we know why it's happening with these code blocks but not the others?
Let's create examples to make sure we understand what is the problem. Adding the ignore is not a bad idea.
I attempted to lint the below example with and without the markdown code block. It seems to be treating the markdown code fencing as another markdown, and the text inside the fence block is being formatted as a paragraph. The linter script passes --prose-wrap argument to Prettier. It reflows any lines that are not fenced code or bullet lists into a single wrapped paragraph. When markdown is not used, Prettier is considering it as a fenced block and stops formatting.
```markdown
[tool.poetry.dependencies]
...
pytest-timeout = "*"
...
[tool.poetry.dependencies]
...
pytest-timeout = "*"
...
So the conclusion is that we'll turn "```markdown" into "```text" (for example), and problem solved?
So the conclusion is that we'll turn "
markdown" into "text" (for example), and problem solved?
Yes, this is one solution, or adding ignore is another solution. Let me know which solution to implement.
So the conclusion is that we'll turn "
markdown" into "text" (for example), and problem solved?
The "text" solution and <!-- prettier-ignore --> are both working. Would you like me to add the test case in dev_scripts_helpers/documentation/test/test_dockerized_prettier.py?
I would go for the "text" solution, and make this a test in linters.
@sandeepthalapanane as a note in general, you don't have to confirm all of your decisions. In many cases you can use your best judgement to come up with a course of action, file a PR with implementation and assign us as reviewers - then we will take a look and go from there. If it's something more complex, that would require a lot of time and effort to implement, then getting approval beforehand makes more sense, but then try to propose solutions rather than ask questions.
Done