Skip to content

Conversation

@Shrikantgiri25
Copy link
Contributor

@Shrikantgiri25 Shrikantgiri25 commented Nov 21, 2025

Description

Currently, code blocks in the DRF documentation must be copied manually. This PR introduces a “Copy” button for code blocks to improve usability.

Scope: Docs-only improvement — does not modify DRF library or API.

Implementation:

Files and Purpose:

1. css/copy-button.css – Styles the copy button, positions it inside code blocks, and applies DRF’s red theme color for consistency.

2. js/copy-button.js – Adds a “Copy” button to each <pre><code> block, handles the clipboard copy functionality, and provides user feedback (“Copied!”).
 
3. mkdocs.yml – Registers the CSS and JS files so they are loaded with the documentation.
 
4.  main.html – Ensures the extra CSS is included in the page layout.

Discussion - #9829

Screenshots:
image

image

@p-r-a-v-i-n
Copy link
Contributor

I may be completely wrong here, but adding new features or code formatting changes is not allowed according to the DRF policy. This would violate the DRF policy.
As per the policy, DRF is already feature complete. though the requested feature relates to the documentation, it involves code changes, so I don't think it will be accepted.

@Shrikantgiri25
Copy link
Contributor Author

I may be completely wrong here, but adding new features or code formatting changes is not allowed according to the DRF policy. This would violate the DRF policy.
As per the policy, DRF is already feature complete. though the requested feature relates to the documentation, it involves code changes, so I don't think it will be accepted.

Thanks for the feedback.
This PR doesn’t introduce any DRF features or library changes.
It only updates the documentation theme (CSS/JS), and DRF’s contributing guide explicitly states that documentation improvements are welcome.
If the maintainers prefer to avoid UX changes in the docs, I’m happy to follow their direction.

Copy link
Member

@browniebroke browniebroke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! I noted a few things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants