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

DocGen Copy button for code snippets #18944

Closed
ringabout opened this issue Oct 2, 2021 · 6 comments · Fixed by #18963
Closed

DocGen Copy button for code snippets #18944

ringabout opened this issue Oct 2, 2021 · 6 comments · Fixed by #18963
Labels
Documentation Generation Related to documentation generation (but not content). Easy Hacktoberfest (Open) Issues suitable for Hacktoberfest, open for working on.

Comments

@ringabout
Copy link
Member

Would be great to add a "Copy" button to the code blocks rendered by the Docgen,
just like GitHub itself has nowadays on the code blocks, the Docgen needs to add 1 line:

<button onclick="document.querySelector('#SELECTOR').select();document.execCommand('copy');">Copy</button>

I copied from timotheecour#802
@juancarlospaco

@ringabout ringabout added Easy Documentation Generation Related to documentation generation (but not content). Hacktoberfest (Open) Issues suitable for Hacktoberfest, open for working on. labels Oct 2, 2021
@vj-abishek
Copy link
Contributor

I would like to contribute to this awesome project. Would you guide me on which file should I change?

Here is my quick prototype

image

@ringabout
Copy link
Member Author

ringabout commented Oct 3, 2021

Hi @vj-abishek

You may start from here:

proc getAllRunnableExamplesImpl(d: PDoc; n: PNode, dest: var ItemPre,

proc renderCode(d: PDoc, n: PRstNode, result: var string) =

https://github.com/nim-lang/Nim/blob/devel/tools/dochack/dochack.nim

After fixing the file, you can use koch temp doc -r ... to test whether the fix works.

@vj-abishek
Copy link
Contributor

image

I'm getting this error.
How to run locally

@ringabout
Copy link
Member Author

ringabout commented Oct 3, 2021

What's your command? Does /home/abishek/opensource.nim exist? How about putting the file under /Nim directory?

@vj-abishek
Copy link
Contributor

vj-abishek commented Oct 3, 2021

I ran ./koch temp doc -r ..
When I run koch temp doc -r .. it says command not exists

Does /home/abishek/opensource.nim exist?

No

How about putting the file under /Nim directory?

The dir structure is /home/abishek/opensource/Nim

Any documentation available on how to run locally. That docs page

@ringabout
Copy link
Member Author

ringabout commented Oct 3, 2021

I ran ./koch temp doc -r ..

Well, I mean ./koch temp doc -r yourdocfile.nim 😄
The reference docs: https://nim-lang.github.io/Nim/koch.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Generation Related to documentation generation (but not content). Easy Hacktoberfest (Open) Issues suitable for Hacktoberfest, open for working on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants