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

Don't execute certain blocks #18

Open
natew opened this issue Jun 3, 2018 · 15 comments
Open

Don't execute certain blocks #18

natew opened this issue Jun 3, 2018 · 15 comments

Comments

@natew
Copy link

natew commented Jun 3, 2018

I just want to have some blocks be documenting how to use it, and then later define how it works.
So imagine that this would work (note the first blocks don't define a scripting language). Perhaps another thing like <!-- ignore --> would be better, so you can have it look like bash still.

run

Run npm in any apps/app folder, defaults to start. To run every app in dev mode for example just do:

maid run app
maid run desktop
maid run electron

which will end up running:

cd apps/app && npm run start
cd apps/desktop && npm run start
cd apps/electron && npm run start

But you can run any arbitrary npm command inside any package here too by using the fourth argument. So, maid run app build would run npm run build inside apps/app.

echo "hi"
cd apps/$1 || echo "not found" && exit 1
pwd
@zephraph
Copy link
Contributor

zephraph commented Jun 3, 2018

I think this would be easy enough to do with something like

<!-- maid-ignore-start -->
```bash
maid run app
maid run desktop
maid run electron
```
<!-- maid-ignore-end -->

We could just take the processed markdown snippet and remove everything between those comments.

@natew
Copy link
Author

natew commented Jun 3, 2018 via email

@zephraph
Copy link
Contributor

zephraph commented Jun 3, 2018

I suppose it'd be possible to just use <!-- maid-ignore --> and have that skip the next code block that it finds. That'd just be trickier to implement because it has to look ahead for the next code block and pull that out. Do you have any suggestions?

@natew
Copy link
Author

natew commented Jun 3, 2018 via email

@zephraph
Copy link
Contributor

zephraph commented Jun 3, 2018

It seems to work...

echo test
```bash @ignore
echo test
```

I'm not sure if it'd have wider negative implications though.

@zephraph
Copy link
Contributor

zephraph commented Jun 3, 2018

Actually, @natew, this might actually work now. bash @ignore won't be treated as a known type therefore shouldn't actually be ran... give it a try?

@tunnckoCore
Copy link
Contributor

tunnckoCore commented Jun 3, 2018

Don't think only for github. Those readmes are rendered in ton of places like NPM and such that rely on NPM registry to pull package readme.

maid-ignore-start and *-end may be a bit verbose but is the best, definitely.
Don't be soooooooo lazy 😆

@natew
Copy link
Author

natew commented Jun 3, 2018 via email

@tunnckoCore
Copy link
Contributor

tunnckoCore commented Jun 3, 2018

It's hidden to the consumers anyway. And it is enough good and explicit. Verbose things some times are good thing. And i'm always for explicitness. It might be even more confusing for some people when it only depend on just maid-ignore - what that ignores? only next? only next few? only next what? next few code blocks? and etc.

Pragma feels good too, but we are not sure where these files are rendered. Oh, one more place - yarn's package site.

@natew
Copy link
Author

natew commented Jun 3, 2018 via email

@chrisdmacrae
Copy link

Could this not be done with a custom code block identifier, specifically for commenting?

 ```maidcomment
  // code

@zephraph
Copy link
Contributor

zephraph commented Jun 5, 2018

It could, but you'd break syntax highlighting.

@chrisdmacrae
Copy link

Totally valid point @zephraph. Just tested the @ignore syntax and it worked across the board. That's nicer.

@tunnckoCore
Copy link
Contributor

We are not in javascript world and i don't understand why we should rely on pragmas or such, instead of just html comment as normally all will expect to work and it totally make sense to be that way.

Most markdown tools are using html comments - such example MarkdownLint? Not to mention that there's one more thing - Prettier for markdown may stop work? It works.

"Please be explicit" is my motto.

@zephraph
Copy link
Contributor

zephraph commented Jun 6, 2018

The pragma works as is because it's no longer recognized as a runnable type. Technically you could put anything there that wasn't a supported type and it would be preserved. In this case, Github at the very least still syntax highlights. That means there's no changes needed to support doing

```bash @ignore
echo "Don't run this with maid"
```

I think it would be easy enough to add the html comment though.

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

No branches or pull requests

4 participants