djangoproject.com
djangoproject.com copied to clipboard
Add Click to copy text for commands present in the official Django website.
As I am following through the Django project tutorial in the official Django website there are so many commands like below, so adding a click to copy text would be a time saver.
Before :

After :

I would like to work on that issue
There's a Sphinx copy button extension: https://sphinx-copybutton.readthedocs.io/en/latest/ — looking into adapting that would be good.
- What's the HTML it outputs?
- What's the static file we'd need to include.
The docs aren't raw sphinx HTML. We use the JSON builder, and then insert the body into a Django template.
yes if we used Sphinx copy button extension the ouputs are as follows
I have added sphinx_copybutton
in extensions in conf.py file in docs folder.
BEFORE :

AFTER :

It seems some code blocks already have this feature (clipboard.js). Perhaps we can just utilize that but I like the style of the Sphinx copy button for 1 line commands.
I'd be willing to work on this if it's still open.

import django print(django.get_version()) 4.2
sphinx-copybutton also uses clipboard.js - so I guess it's a matter of avoiding loading the same JS library twice if its included through the Sphinx extension. If the copy of the JS library included in sphinx-copybutton
can be used for the Django project (or the other way around), then we can also avoid having the same asset from different sources and with different versions. But other than that, seems like it's possible to use the same styles, HTML elements and JS library on the entire website, as well as isolated Sphinx documentation builds :+1:
I would like to contribute to this.
@rabahalishah feel free to work on this, no need to be assigned to work on an issue :)
There's a class of code-block-caption
which adds the styling and the copy button, but the JS doesn't appear to be loaded by default.
This class and snippet
are hooked up to clippify
, but they don't appear to be in use anywhere at the moment.
https://github.com/django/djangoproject.com/blob/main/djangoproject/static/js/main.js#L101
@VenkataBhaskarr Please Assign Me This Issue. I Want To Work On this Issue.
@Yadnyesh-Dashpute you don't need to be assigned. People can see now that you will be working on this so go ahead and raise a PR when you have something to look at 👍
@marksweb Okay
I would like to work on this issue.
@Om15102003 There's already an open PR for this here; #1434
If you find something you'd like to work on, just go ahead and work on it - there's no need to ask. Though it's worth looking to see if anybody has mentioned that they might be working on it or if there are linked PRs. Quite often someone might say they're going to look at something, but unless there's a PR we don't really know the status of that, so bare in mind how long it has been since someone talked about working on something.
Hello sir. I'm very new in opensource coding.. but I think I can resolve this problem . but I'm confused from which file is this issue is related to ?? would you please guide me ??