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

Remove unused links from docs #5735

Merged
merged 1 commit into from
Jan 15, 2018
Merged

Remove unused links from docs #5735

merged 1 commit into from
Jan 15, 2018

Conversation

jdufresne
Copy link
Contributor

Each removed link has no inline use.

Copy link
Collaborator

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

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

Wowser. Great.

I presume you used a tool for this...? 🙂

@tomchristie
Copy link
Member

Yeah, nicely done! I guess we want to verify these before we merge this in.

I presume you used a tool for this...? 🙂

Same question here!

Each removed link has no inline use.
@jdufresne
Copy link
Contributor Author

I noticed some of these links were unused while working on #5729. I wrote the following script to find them all:

#!/usr/bin/env python3

import os
import re
import subprocess

link_re = re.compile(r'^(\[.*\]):')

prune_name = [
    '.git',
    '.hg',
    '.tox',
    '__pycache__',
    'LC_MESSAGES',
    'node_modules',
]


root = os.getcwd()
for dirpath, dirnames, filenames in os.walk(root):
    for name in prune_name:
        try:
            dirnames.remove(name)
        except ValueError:
            pass

    for fn in filenames:
        _, ext = os.path.splitext(fn)
        if ext == '.md':
            links = []
            path = os.path.join(dirpath, fn)
            with open(path) as fp:
                for line in fp:
                    match = link_re.match(line)
                    if match:
                        links.append(match.group(1))
            for link in links:
                cmd = [
                    'grep',
                    '-c',
                    '-F', link,
                    path,
                ]
                out = subprocess.check_output(cmd)
                count = int(out.strip())
                if count < 2:
                    print(path, link, count)

@carltongibson carltongibson added this to the 3.8 Release milestone Jan 15, 2018
@carltongibson carltongibson merged commit d5c34aa into encode:master Jan 15, 2018
@jdufresne jdufresne deleted the unused-links branch January 26, 2018 02:07
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
Each removed link has no inline use.
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.

4 participants