Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: use custom diff code blocks#5099

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 8 commits intotypescript-eslint:mainfromJosh-Cena:avoid-diff
Jun 10, 2022

Conversation

Josh-Cena
Copy link
Member

@Josh-CenaJosh-Cena commentedMay 30, 2022
edited
Loading

PR Checklist

Overview

The diff makes the code not directly copyable, which is not something you want for tutorial examples.

See related discussions at:

@nx-cloud
Copy link

nx-cloudbot commentedMay 30, 2022
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitff80b53. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 fromNxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@Josh-Cena!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day.

@netlify
Copy link

netlifybot commentedMay 30, 2022
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitff80b53
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6295cd520581c60009c95108
😎 Deploy Previewhttps://deploy-preview-5099--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site settings.

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

Is this something we can build a docusaurus plugin for? To add the +/- in via css so the content is copyable?

I personally like diffs as it clearly shows what changes should be made which helps tell the story of how to configure things, IMO

armano2 and JoshuaKGoldberg reacted with thumbs up emoji
@Josh-Cena
Copy link
MemberAuthor

Josh-Cena commentedMay 30, 2022
edited
Loading

We can, absolutely. but it would still mean showing two competing lines and when users copy, they have to delete the "-" line. Using highlighted lines makes it quite clear as well.

@Josh-Cena
Copy link
MemberAuthor

I don't know what's going on with the Netlify preview, though—it's not showing the latest content😕

@armano2
Copy link
Collaborator

armano2 commentedMay 30, 2022
edited
Loading

I personally like diffs as it clearly shows what changes should be made which helps tell the story of how to configure things

i do agree with that, if we want to make file copyable, maybeuser-select: none; could be used instead? for+ and-

https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/website/src/css/prism.css

.token.prefix {user-select: none;}
JoshuaKGoldberg and bradzacher reacted with thumbs up emoji

@codecov
Copy link

codecovbot commentedMay 30, 2022
edited
Loading

Codecov Report

Merging#5099 (ff80b53) intomain (c9c0569) willdecrease coverage by0.38%.
The diff coverage isn/a.

@@            Coverage Diff             @@##             main    #5099      +/-   ##==========================================- Coverage   91.70%   91.32%   -0.39%==========================================  Files         362      132     -230       Lines       12181     1487   -10694       Branches     3530      224    -3306     ==========================================- Hits        11171     1358    -9813+ Misses        661       65     -596+ Partials      349       64     -285
FlagCoverage Δ
unittest91.32% <ø> (-0.39%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
...plugin-internal/src/rules/prefer-ast-types-enum.ts
packages/utils/src/eslint-utils/RuleTester.ts
...es/eslint-plugin/src/rules/no-floating-promises.ts
...s/utils/src/ast-utils/eslint-utils/astUtilities.ts
packages/utils/src/ts-eslint-scope/Referencer.ts
...int-plugin/src/rules/strict-boolean-expressions.ts
packages/type-utils/src/getDeclaration.ts
packages/utils/src/ts-eslint-scope/ScopeManager.ts
...ckages/eslint-plugin/src/rules/no-throw-literal.ts
packages/type-utils/src/typeFlagUtils.ts
... and220 more

@bradzacherbradzacher added package: websiteIssues related to the @typescript-eslint website documentationDocumentation ("docs") that needs adding/updating and removed package: websiteIssues related to the @typescript-eslint website labelsMay 30, 2022
@bradzacher
Copy link
Member

https://jsfiddle.net/fp2jrnmv/
Just to show a quick-and-dirty POC of this working in a fiddle.
There is one small issue - we can't prevent copying empty newlines[1] - but it's otherwise perfect.

[1] copying the above example yields:

  module.exports = {    root: true,    parser: '@typescript-eslint/parser',    plugins: [      '@typescript-eslint',    ],    extends: [     'airbnb-typescript',    ],  };

Another option (or an additional option) could be to use JS to add a copy button which completely deletes the deleted lines from the copied contents.

@bradzacherbradzacher added the awaiting responseIssues waiting for a reply from the OP or another party labelMay 30, 2022
@armano2
Copy link
Collaborator

armano2 commentedMay 30, 2022
edited
Loading

There is one small issue - we can't prevent copying empty newlines[1]

.language-diff .token-line> .prefix,/* you want to remove all prefixes, as non modifed lines have extra space */.language-diff .token-line> .deleted,/* remove deleted elements */.language-diff .token-line> .deleted+br {/* remove new line after deleted elements */user-select: none;}
bradzacher reacted with thumbs up emoji

@bradzacher
Copy link
Member

@armano2 - ah I missed thebrs!

The result of the copy paste with armano's updated css

https://jsfiddle.net/fmt0h31z/

  module.exports = {    root: true,    parser: '@typescript-eslint/parser',    plugins: [      '@typescript-eslint',    ],    extends: [     'airbnb-typescript',    ],  }

This isexactly what we want - you can copy paste the true snipped AND we get to show the changes to tell a story.
I love it!

@Josh-Cena
Copy link
MemberAuthor

Josh-Cena commentedMay 31, 2022
edited
Loading

Great, I'll implement this and you can see the effect (hopefully—if the deploy preview updates)

Also, what do we do about the copy button? Should we hide it entirely, or do you want it to have custom behavior as well?

bradzacher reacted with heart emoji

@bradzacher
Copy link
Member

Also, what do we do about the copy button? Should we hide it entirely, or do you want it to have custom behavior as well?

If it's not too difficult - having it do the same thing (copy the "intended" code) would be great!
Otherwise I'm happy for it to be hidden if it's too hard to customise.

Comment on lines +142 to +158
magicComments: [
{
className: 'theme-code-block-highlighted-line',
line: 'highlight-next-line',
block: { start: 'highlight-start', end: 'highlight-end' },
},
{
className: 'code-block-removed-line',
line: 'Remove this line',
block: { start: 'Removed lines start', end: 'Removed lines end' },
},
{
className: 'code-block-added-line',
line: 'Add this line',
block: { start: 'Added lines start', end: 'Added lines end' },
},
],
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

New Docusaurus feature to add custom metadata to lines—suits this use-case quite well.

I prefer using human-readable identifiers like "Remove this line", but if you want something that stands out more like for machines (e.g. "remove-next-line") just let me know

@Josh-Cena
Copy link
MemberAuthor

Josh-Cena commentedMay 31, 2022
edited
Loading

Ahhh... Customizing the copy button, even hiding it, is a bit hard at this stage. This would need some refactors in Docusaurus, but I'm not sure how. I hope the current solution is good enough.

@Josh-Cena
Copy link
MemberAuthor

Current UI/UX is quite good IMO. We have syntax highlighting which is missed in diff code blocks. It's also more obvious that the+/- are non-text tokens because they are shifted left.

bradzacher reacted with heart emoji

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

Whilst I would love if we could just usediff cos it's concise - i think the syntax highlighting we get from usingjs is better and paired with the new UX is well worth it.

keanubeautiful

@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelJun 10, 2022
@bradzacherbradzacher changed the titledocs: avoid using diff code blocksdocs: use custom diff code blocksJun 10, 2022
@bradzacherbradzacher merged commit331ff3b intotypescript-eslint:mainJun 10, 2022
@Josh-CenaJosh-Cena deleted the avoid-diff branchJune 10, 2022 04:19
@Josh-Cena
Copy link
MemberAuthor

Josh-Cena commentedJun 10, 2022
edited
Loading

Cross-posting fromfacebook/react-native-website#2984 — we'll probably consider making this the default behavior in Docusaurus.

bradzacher reacted with heart emoji

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 11, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
documentationDocumentation ("docs") that needs adding/updating
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Josh-Cena@armano2@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp