diff --git a/doc/guide.md b/doc/guide.md index abe4108ce..83fe8b0fa 100644 --- a/doc/guide.md +++ b/doc/guide.md @@ -62,7 +62,7 @@ Rabit provides different reduction operators, for example, if you change ```op: the reduction operation will be a summation, and the result will become ```a = {1, 3, 5}```. You can also run the example with different processes by setting -n to different values. -If you are more familiar with python, you can also use rabit in python. The same example as before can be found in [basic.py](basic.py): +If you are more familiar with python, you can also use rabit in python. The same example as before can be found in [basic.py](../guide/basic.py): ```python import numpy as np diff --git a/doc/sphinx_util.py b/doc/sphinx_util.py index c025a9c74..95f8823d3 100644 --- a/doc/sphinx_util.py +++ b/doc/sphinx_util.py @@ -14,13 +14,19 @@ from recom import parser class MarkdownParser(parser.CommonMarkParser): github_doc_root = None + doc_suffix = set(['md', 'rst']) @staticmethod def remap_url(url): if MarkdownParser.github_doc_root is None or url is None: return url + if url.startswith('#'): + return url arr = url.split('#', 1) - if arr[0].endswith('.md') and arr[0].find('://') == -1: + ssuffix = arr[0].rsplit('.', 1) + + if len(ssuffix) == 2 and (ssuffix[-1] in MarkdownParser.doc_suffix + and arr[0].find('://') == -1): arr[0] = arr[0][:-3] + '.html' return '#'.join(arr) else: