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

Embed source code snippets from example repos #4276

Open
zeitlinger opened this issue Apr 10, 2024 · 6 comments
Open

Embed source code snippets from example repos #4276

zeitlinger opened this issue Apr 10, 2024 · 6 comments
Labels
enhancement New feature or request sig:java

Comments

@zeitlinger
Copy link
Member

I'd like to embed code snippets on the website

@svrnm
Copy link
Member

svrnm commented Apr 10, 2024

Thanks @zeitlinger, just adding some of our slack conversation for context:

  • We already support embedding code (and keeping it in sync) via code_excerpter, as implemented in this PR for go getting started: [CI] Support code-snippet extraction and docs-updating #3948
  • This implementation is still under test, so we try to not open the flood gates yet. I would be open to add this as yet another example, but I would like to get other maintainers (and especially @chalin) to express their opinion.

@zeitlinger
Copy link
Member Author

Great - I'll just wait for more feedback on this issue 😄

@theletterf theletterf added the discussion Input from everyone is helpful to drive this forward label Apr 12, 2024
@theletterf
Copy link
Member

I suggest moving this to Discussion.

@chalin
Copy link
Contributor

chalin commented Apr 12, 2024

As Severin pointed out in Slack, we have some tooling setup for code snippet refresh already, and it's tooling that has been used (for almost 9 years) and continues to be in use at Google, so it is well vetted; and the tools continue to be updated -- for the (current) canonical home of the tools, see https://github.com/dart-lang/site-shared/tree/main/packages. (Insider note that a JS rewrite of the tooling is in the works.)

I took a quick look at embedmd and I get the impression that it figures out which lines of code to bring in based on regexes. This is only one of the snippet extraction modes supported by the current tools, and generally not the preferred one given that it can be brittle. In the experiences I've had at Google maintaining websites with lots of code snippets, generally the best option (least brittle) is to add annotations to the source files for the purpose of delimiting code snippets. This makes it more obvious to developers when they update the code as to whether their changes might impact (and possibly break) code snippet extraction.

That being said, if you want to only use regexes with the current tooling you can.

I hope this helps.

FYI, I'm at half time this month and OOO all of next week. I'd be glad to work through a more complete example of the use of the current tooling, but it probably won't be until the end of the month. I'll do my best to answer any questions you might have as soon as I'm available.

@svrnm svrnm added enhancement New feature or request sig:java and removed discussion Input from everyone is helpful to drive this forward labels Apr 15, 2024
@svrnm
Copy link
Member

svrnm commented Apr 15, 2024

I suggest moving this to Discussion.

I think this is a very concrete ask (add code sync for java) with a binary answer (yes we do this, here is a PR, no we don't do this, close this issue), so a discussion might not be necessary.

on topic @chalin: would you be fine with @zeitlinger creating a PR for what he wants to accomplish using the current tooling (code_excerpter)?

@chalin
Copy link
Contributor

chalin commented Apr 22, 2024

@chalin: would you be fine with @zeitlinger creating a PR for what he wants to accomplish using the current tooling (code_excerpter)?

Yes, of course! 🙌🏻

There is one tweak that I want to make to the tooling so that it plays more nicely with Prettier, but the tools are usable as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sig:java
Projects
None yet
Development

No branches or pull requests

4 participants