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

lint: inconsistent fenced code block -line indentation #554

Closed
jorgeorpinel opened this issue Aug 13, 2019 · 8 comments · Fixed by #555
Closed

lint: inconsistent fenced code block -line indentation #554

jorgeorpinel opened this issue Aug 13, 2019 · 8 comments · Fixed by #555
Labels
A: docs Area: user documentation (gatsby-theme-iterative) 🐛 type: bug Something isn't working.

Comments

@jorgeorpinel
Copy link
Contributor

jorgeorpinel commented Aug 13, 2019

A problem after implementing #372 is that some lines inside md fenced code blocks starting with - get indented for unknown reasons by Prettier.

E.g. by finding the regex ^- cache in all files we can see that static/docs/commands-reference/commit.md has the unindented lines:

image

Similar cases in static/docs/get-started/connect-code-and-data.md and static/docs/tutorial/define-ml-pipeline.md

However static/docs/commands-reference/add.md has them indented:

image

I don't see a clear pattern explaining this apparently erratic behavior but it's all over the docs.

Again, this i work of Prettier which has been run on all md files in #512. None of the DVC-file samples had indentation before - lines originally. We decided that the indentation was OK in #512 (comment) but the fact that it indents some and unindents others troubles me a little. Perhaps we should use <!-- prettier-ignore -->s before all YAML code blocks after all?

All these code samples are still valid YAML though so please just close this issue if the decision is to live with it and let prettier do whatever it wants 😋


Originally reported partially as lint: don't indent fenced code block contents

@shcheklein
Copy link
Member

I would actually create a ticket on the Prettier's repo to be honest. For us it does not look very important to include special instructions.

@shcheklein
Copy link
Member

Closing this for now :)

@jorgeorpinel
Copy link
Contributor Author

jorgeorpinel commented Aug 13, 2019

Good call, I started opening an issue at https://github.com/prettier/prettier/issues/new?template=formatting.md but in the process I discovered why this is happening!

The blocks that don't get indented have repeated keys inside the YAML blocks so actually they're NOT valid YAML. Prettier tries to run the YAML linter inside, but simply fails to parse them with error message SyntaxError: Map keys must be unique; (See this playground).

Should we be worried that some of our DVC-file aren't technically valid YAML @shcheklein ? More of a Q for the core repo but asking here anyway. cc @efiop

@shcheklein
Copy link
Member

there is a bug in docs - in the first example, third md5 from the top should not be indented at all. It's a top-level md5.

@shcheklein
Copy link
Member

reopening it to check the docs and linting for this bug

@shcheklein shcheklein reopened this Aug 13, 2019
@shcheklein shcheklein added 🐛 type: bug Something isn't working. A: docs Area: user documentation (gatsby-theme-iterative) labels Aug 13, 2019
@jorgeorpinel
Copy link
Contributor Author

Hmm I see. OK I fixed that in 5f13d5c but what about the other 2 examples I mentioned?

Here's a playground for static/docs/get-started/connect-code-and-data.md. In this case it complaints that SyntaxError: Document is not valid YAML (bad indentation?) (5:1)

And in this playground for static/docs/tutorial/define-ml-pipeline.md quite simply since the block langauge is ```dvc (unknown to Prettier) it ignores it. I can fix that by making sure all YAML samples are in '''yaml language blocks.

@shcheklein
Copy link
Member

The first one should be like this:

cmd: python src/prepare.py data/data.xml
deps:
- md5: b4801c88a83f3bf5024c19a942993a48
  path: src/prepare.py
- md5: a304afb96060aad90176268345e10355
  path: data/data.xml
md5: c3a73109be6c186b9d72e714bcedaddb
outs:
- cache: true
  md5: 6836f797f3924fb46fcfd6b9f6aa6416.dir
  metric: false
  path: data/prepared
wdir: .

or like this:

cmd: python src/prepare.py data/data.xml
deps:
  - md5: b4801c88a83f3bf5024c19a942993a48
    path: src/prepare.py
  - md5: a304afb96060aad90176268345e10355
    path: data/data.xml
md5: c3a73109be6c186b9d72e714bcedaddb
outs:
  - cache: true
    md5: 6836f797f3924fb46fcfd6b9f6aa6416.dir
    metric: false
    path: data/prepared
wdir: .

@jorgeorpinel
Copy link
Contributor Author

Great. Yeah, Prettier forces it into the 2nd form you provided. Fixed all in b5cd910

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: docs Area: user documentation (gatsby-theme-iterative) 🐛 type: bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants