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

Add anchors to bullets #338

Merged
merged 1 commit into from
Jul 18, 2014
Merged

Add anchors to bullets #338

merged 1 commit into from
Jul 18, 2014

Conversation

todb-r7
Copy link

@todb-r7 todb-r7 commented Jul 15, 2014

Every bullet is anchored with a short <a name> tag and includes a superscript link anchor at the end. This makes life easier for me when I want to refer people to a particular guideline, such as:

https://github.com/rapid7/ruby-style-guide/blob/add-anchors/README.md#no-and-or-or

When dealing with new Rubyists and their contributions to my project, I want to drop them exactly on what rule I'm talking about when they don't know about the Ruby Style Guide, instead of telling them to scroll around or ctrl-F or anything like that.

This PR implements many of the suggestions in #319.

@todb-r7
Copy link
Author

todb-r7 commented Jul 15, 2014

These margins will want to be reset eventually. First attempt at auto-resetting with VIM gqG was kind of a disaster.

@Ajedi32
Copy link

Ajedi32 commented Jul 17, 2014

This pull request adds anchors, but doesn't seem to include any user-friendly way of discovering them.

See also #319

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 17, 2014

Yeah, as I already mentioned in #319 I think that the superscript [link] at the end of each rule is the way to go.

@bruno-
Copy link
Contributor

bruno- commented Jul 17, 2014

When this is updated and merged this guide will ✨

@todb-r7
Copy link
Author

todb-r7 commented Jul 17, 2014

Thanks for the pointer! I was experimenting with some linking tactics -- my only light concern with linking at the end was that you'd end up on the last of a multiline bullet. But, I can't figure any other way while retaining any kind of sane formatting.

@Ajedi32
Copy link

Ajedi32 commented Jul 17, 2014

@todb-r7 Check out the second approach I suggested in #319:

This style is also very unobtrusive and clear in the rendered markdown, and the anchor points to the beginning of the line. The plain-text is a bit uglier though.

  • Use Unix-style line endings. (*BSD/Solaris/Linux/OS X users are covered by default, Windows users have to be extra careful.) [[link](#unix-line-endings)]

Source at start of bullet:

<div name="unix-line-endings"></div>

Source at end of bullet:

<sup>[[link](#unix-line-endings)]</sup>

Basically, I suggested putting the anchor itself at the start of the bullet while still putting the link at the end.

@todb-r7
Copy link
Author

todb-r7 commented Jul 17, 2014

I'm implementing the end of line anchors now.

@todb-r7
Copy link
Author

todb-r7 commented Jul 17, 2014

@bbatsov what do you think?

@todb-r7
Copy link
Author

todb-r7 commented Jul 17, 2014

Incidentally, I profess my love for your work on our company blog. Thanks!

@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

Updated the description to reflect the current state of the PR.

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 18, 2014

Looks good to me. Squash all the commits into one and we'll be good to go.

@bruno-
Copy link
Contributor

bruno- commented Jul 18, 2014

I just checked @todb-r7's branch and I found:

  • the first anchor in this section jumps to an unexpected paragraph
  • this paragraph and the one below it have the same link percent-q

Btw fantastic job 👍

@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

I'll fix the problems described by @bruno- but just out of curiosity, would you like me to squash commits and force push, or open another branch? I can do either (personally I don't care about lots of small changes and backtracks, but I'm not a heavy git bisect user.)

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 18, 2014

Squash and force push.

@todb-r7 todb-r7 closed this Jul 18, 2014
@todb-r7 todb-r7 deleted the add-anchors branch July 18, 2014 16:04
todb-r7 pushed a commit to rapid7/ruby-style-guide that referenced this pull request Jul 18, 2014
Adds deep links to the end of every bullet.

Squashed commit of the following:

commit d9805da
Author: Tod Beardsley <todb@metasploit.com>
Date:   Fri Jul 18 10:57:50 2014 -0500

    Fix problems spotted by @bruno-

commit 84e3091
Merge: f0bb833 4038e21
Author: Tod Beardsley <todb@metasploit.com>
Date:   Thu Jul 17 16:52:47 2014 -0500

    Merge branch 'findable-anchors' into add-anchors

    This adds the ending `[link]` tags to the first paragraph of every
    bullet point. It's a fairly pleasant format.

commit 4038e21
Author: Tod Beardsley <todb@metasploit.com>
Date:   Thu Jul 17 16:51:47 2014 -0500

    Remove trailing whitespace.

commit 00137fc
Author: Tod Beardsley <todb@metasploit.com>
Date:   Thu Jul 17 16:49:40 2014 -0500

    Rejoin the bullets so they'll render right

commit b76cb0c
Author: Tod Beardsley <todb@metasploit.com>
Date:   Thu Jul 17 16:46:54 2014 -0500

    Justify the paragraphs of bullets to 78 cols

commit f35675d
Author: Tod Beardsley <todb@metasploit.com>
Date:   Thu Jul 17 16:19:38 2014 -0500

    Add trailing link buttons.

    This also reformats every line to be one long line. That will want to
    get fixed next, but this made a quick macro substitution for every
    anchor easier.

commit 154f7dd
Author: Tod Beardsley <todb@metasploit.com>
Date:   Thu Jul 17 15:51:45 2014 -0500

    Trying with line breaks.

commit f0bb833
Author: Tod Beardsley <todb@metasploit.com>
Date:   Tue Jul 15 16:44:32 2014 -0500

    The rest of the anchors

    Yay now we can navigate this thing.

commit aeb8444
Author: Tod Beardsley <todb@metasploit.com>
Date:   Tue Jul 15 15:42:01 2014 -0500

    Whoopsed a newline

commit 6398955
Author: Tod Beardsley <todb@metasploit.com>
Date:   Tue Jul 15 15:39:50 2014 -0500

    First set of name anchors

    This adds a bunch of blank name anchors and fills in the Source Code
    Layout secion.

    Reformatting line lengths will come later.
@todb-r7 todb-r7 reopened this Jul 18, 2014
@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

Man I can't just force push i always do this delete and re-push dance so I'm sure. I can't do it!

@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

But commit 4bd7012 is up, as well as the original set of commits, now at https://github.com/rapid7/ruby-style-guide/tree/nonsquashed-add-anchors (for future readability until I toss that branch).

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 18, 2014

No need to preserved the complete commit history. For most people it'd be best of the commit message was simple [Fix #319] Add anchors to rule bullets (or something similar).

@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

Ah gotcha.

This adds subtle and nonugly link markup to every bulleted rule for ease
of deeplinking.
@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

Rewriting history always creeps me out, I'm always afraid I'm going to sleep with my grandmother.

bbatsov added a commit that referenced this pull request Jul 18, 2014
@bbatsov bbatsov merged commit 8eb7baa into rubocop:master Jul 18, 2014
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 18, 2014

👍 Great work! (if you're into Rails feel free to update the companion guide as well :-) )

Rewriting history always creeps me out, I'm always afraid I'm going to sleep with my grandmother.

I'm sensing a Futurama reference here. :-)

@bruno-
Copy link
Contributor

bruno- commented Jul 18, 2014

So much win here guys 👍

@todb-r7
Copy link
Author

todb-r7 commented Jul 18, 2014

Yeah sure. It looks to be about the same length. Thanks!

@Ajedi32
Copy link

Ajedi32 commented Jul 18, 2014

👍 Awesome!

todb-r7 pushed a commit to rapid7/rails-style-guide that referenced this pull request Jul 21, 2014
This is very similiar to the formatting used in

rubocop/ruby-style-guide#338

and was requested by @bbatsov to be applied to this Rails guide as well.

Much easier the second time around. :)
fortissimo1997 added a commit to fortissimo1997/ruby-style-guide that referenced this pull request Jul 23, 2014
marocchino pushed a commit to marocchino/ruby-style-guide that referenced this pull request Aug 11, 2015
shyouhei pushed a commit to shyouhei/ruby-style-guide that referenced this pull request Nov 11, 2015
shyouhei pushed a commit to shyouhei/ruby-style-guide that referenced this pull request Nov 11, 2015
Good725 added a commit to Good725/style-guide-rails that referenced this pull request Feb 19, 2020
This is very similiar to the formatting used in

rubocop/ruby-style-guide#338

and was requested by @bbatsov to be applied to this Rails guide as well.

Much easier the second time around. :)
goldapple911 added a commit to goldapple911/rails-style-guide that referenced this pull request Aug 15, 2023
This is very similiar to the formatting used in

rubocop/ruby-style-guide#338

and was requested by @bbatsov to be applied to this Rails guide as well.

Much easier the second time around. :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants