From fdb4e4f319d963ae221e2c6cebac71be5a4079f0 Mon Sep 17 00:00:00 2001 From: Kim Grasman Date: Wed, 2 Sep 2015 22:35:48 +0200 Subject: [PATCH] Rewrite relative links so they can be followed on GitHub. --- README.md | 4 ++-- make_readme.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index defc1e7..677f421 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Include What You Use # -This README was generated on 2015-08-30 20:07:32 UTC. +This README was generated on 2015-09-02 20:35:20 UTC. For more in-depth documentation, see http://github.com/include-what-you-use/include-what-you-use/tree/master/docs. @@ -116,5 +116,5 @@ If you don't like the way `fix_includes.py` munges your `#include` lines, you ca * If `fix_includes.py` has wrongly added or removed a forward-declare, just fix it up manually. * If `fix_includes.py` has suggested a private header file (such as ``) instead of the proper public header file (``), you can fix this by inserting a specially crafted comment near top of the private file (assuming you can write to it): '`// IWYU pragma: private, include "the/public/file.h"`'. -Current IWYU pragmas are described in [IWYUPragmas](IWYUPragmas.md). +Current IWYU pragmas are described in [IWYUPragmas](docs/IWYUPragmas.md). diff --git a/make_readme.py b/make_readme.py index 2b6e334..272d10e 100755 --- a/make_readme.py +++ b/make_readme.py @@ -10,6 +10,7 @@ ##===----------------------------------------------------------------------===## from __future__ import print_function +import re import sys from datetime import datetime @@ -42,6 +43,15 @@ def Heading(): return '\n'.join(buf) +def RewriteRelativeLinks(content): + def Replace(m): + if not m.group(2).startswith('http'): + return '[' + m.group(1) + '](docs/' + m.group(2) + ')' + return m.group(0) + + return re.sub(r'\[(.*?)\]\((.*?)\)', Replace, content) + + def main(argv): if len(argv) != 1: print(_USAGE, file=sys.stderr) @@ -50,7 +60,7 @@ def main(argv): print(Heading()) with open('docs/InstructionsForUsers.md', 'r') as stream: - print(stream.read()) + print(RewriteRelativeLinks(stream.read())) return 0