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

feature: Get certain structure or function from file to md snippet. #92

Open
bwplotka opened this issue Jul 13, 2022 · 3 comments
Open

Comments

@bwplotka
Copy link
Owner

We often sed to point to certain structure. This is fragile as whenever code changes file, or lines were added before or structure adds or removes lines we have to manually find A - B in `sed -n 'A,,Bp'

It would be easy to just point to struct you want to print in whole package or module 🤗

@olivierlemasle
Copy link
Contributor

I have the same need, and for a PR in custom-metrics-apiserver (kubernetes-sigs/custom-metrics-apiserver#138), I developed a small tool that prints snippets of Go files, to be used with mdox-exec.

I would be happy to use it to contribute it to mdox, as @dgrisonnet suggested.

Is the following syntax suitable?

```go mdox-go-file="main.go" mdox-go-snippets="type=MyStruct,func=main"
// it would print the type MyStruct and the main function (in that order) from main.go
```

However, I'm not sure having this (or having mdox-gen-go-struct in #60) really complies with Unix philosophy (do one thing, do it well)...

@saswatamcode
Copy link
Collaborator

I think this would fit well here, and addresses the sed fragility really well. I would love to see this addition! 🙂
I think mdox aims to fit really well with Go ecosystem in general, so we started initiatives like #60. Wdyt? cc: @bwplotka

@bwplotka
Copy link
Owner Author

Lgtm (: let's aim for some short name of this though.. maybe mdox-go=MyStruct.MyMethod even.

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

3 participants