Opened 15 months ago

Last modified 6 months ago

#34846 assigned Cleanup/optimization

Add "Copy" button to the code snippets in docs.

Reported by: rushabhTt Owned by: Mubeen F.
Component: Documentation Version: 4.2
Severity: Normal Keywords:
Cc: Arthur Vasconcelos Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Dear Django Team,

I'd like to suggest an enhancement for your website. Adding a "copy" button to the code blocks could significantly improve user experience. This feature would allow users to easily copy code snippets, saving them from manually selecting and copying, especially for larger blocks.

A small icon in the top right corner of each code block could serve as this "copy" button. Upon clicking, it would copy the entire block of code to the user's clipboard.

This feature is common on many programming and documentation websites and could be a valuable addition to yours.

Thank you for considering this suggestion.

Best,
hehe

Attachments (1)

Screenshot_20230918_105141.png (58.1 KB ) - added by Mariusz Felisiak 15 months ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Sarah Boyce, 15 months ago

Just a note that I saw a PR for this https://github.com/django/django/pull/16342/

comment:2 by David Sanders, 15 months ago

Possible duplicate of #18721 though that ticket contained 3 separate feature requests.

I'd vote +1 on this, though we may need a forum post to review the options. The plugin suggested in the above PR seems nice because it handles pycon snippets removing prompts & output.

comment:3 by David Sanders, 15 months ago

Component: UncategorizedDocumentation

comment:4 by Sarah Boyce, 15 months ago

I would also +1. I think the request is reasonable and can see how this would be a nice experience when going through the tutorials

by Mariusz Felisiak, 15 months ago

comment:5 by Mariusz Felisiak, 15 months ago

Copy button is already there for file-specific snippets:


comment:6 by Mariusz Felisiak, 15 months ago

Summary: "Enhancing User Experience: The Need for a 'Copy' Button in Django Website Code Blocks"Add "Copy" button to the code snippets in docs.
Triage Stage: UnreviewedAccepted
Type: New featureCleanup/optimization

Sounds good, if there is a reasonable Sphinx plugin.

#18721 was a multi-task ticket so I'd leave it closed.

comment:7 by Saarthak Maini, 15 months ago

Has patch: set
Owner: changed from nobody to Saarthak Maini
Status: newassigned

I have created a Pull Request for this ticket.

Pull Request : https://github.com/django/django/pull/17292

I referenced the pull request ( https://github.com/django/django/pull/16342/ ) mentioned above in the discussion.

I tested it and found that it was only working for text which was starting with "$ " and not covering text starting with "...\>".

So, I used the regex to resolve the issue and made the copy functionality available for both Linux/MacOS Option and Windows Option

comment:8 by David Sanders, 15 months ago

Yeah look I think we should give the original author a chance here instead of just taking over what they did... I mean they're probably patiently waiting for someone to review it. They haven't actually said that they can't continue.

comment:9 by Mariusz Felisiak, 15 months ago

Owner: changed from Saarthak Maini to VenkataBhaskarr
Patch needs improvement: set

comment:10 by Mubeen F., 10 months ago

Owner: changed from VenkataBhaskarr to Mubeen F.

comment:11 by Arthur Vasconcelos, 7 months ago

Cc: Arthur Vasconcelos added
Patch needs improvement: unset

comment:12 by Sarah Boyce, 6 months ago

Patch needs improvement: set

Investigation is required as to whether this shouldn't be solved in djangoproject.com as is the current approach

Note: See TracTickets for help on using tickets.
Back to Top