question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Links in Code Examples (via magic comments)

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Description

Clickable links in code samples. The Firebase documentation uses a similar system for linking code snippets to configuration information: https://firebase.google.com/docs/web/setup#add-sdks-initialize

Example: Screen Shot 2022-04-13 at 10 50 53 AM

The bottom of this section of the doc mentions that the magic comment system could extend in the future for additional markup use cases. I believe this is one potential use case for an extension of that system.

Has this been requested on Canny?

No response

Motivation

In many cases, it makes more sense to surface links through prose or an admonition before or after a code block. But sometimes this:

  • takes up valuable vertical space on an already long page
  • clutters up a page that already contains lots of admonitions
  • creates confusion for users when examples are long and/or need multiple outward links

API design

I’m not super familiar with the implementation for the magic comment system. But right now, that system uses the following syntax for highlights:

// highlight-start
highlighted text
// highlight-end
not highlighted text
// highlight-next-line
highlighted text

I imagine we could extend these magic comments to use an uncommon keyword for linking to a docusaurus ID, with a link name and reference as arguments provided in the markdown format:

// docs-link [Link to something](/absolute/path/to/{id})

Have you tried building it?

no

Self-service

  • I’d be willing to contribute this feature to Docusaurus myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Josh-Cenacommented, Apr 14, 2022

Oh… I just realized this will not be a normal magic comment either! Because the definition of a “magic comment” is something that adds metadata about the next line (e.g. highlight, collapsible), and it will be removed. So we can’t even use the magic comment system here. @slorber We can close this as soon as you make that refactor 👍

1reaction
Josh-Cenacommented, Apr 15, 2022

Now that #7175 is merged, this should be able to be implemented in userland.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Magic Comments
Magic comments are a powerful feature that came to Tinkerwell with version 3. They allow you to debug your code inline without changing...
Read more >
How to use Webpack's new “magic comment” feature with ...
If you were looking for a quick overview of how to weed your way through Webpack stats to utilize the new “magic comment”...
Read more >
Add data.SE style "magic links" to comments
Link text is "minimal reproducible example", or localized text on localized sites. ... In chat, only a limited subset of the magic links...
Read more >
The beginner's guide to magic links
Magic links are a great way to create a smooth login experience for your users. Here's everything you need to know to get...
Read more >
Best practices for writing code comments
Links to standards and other documentation can help readers understand the problem your code is solving. While this information may be somewhere ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found