Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
63bf066e
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
63bf066e
编写于
3月 15, 2021
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve links matching
上级
e7ba9dcd
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
11 addition
and
6 deletion
+11
-6
docs/tools/single_page.py
docs/tools/single_page.py
+11
-6
未找到文件。
docs/tools/single_page.py
浏览文件 @
63bf066e
...
@@ -30,11 +30,17 @@ def generate_anchor_from_path(path):
...
@@ -30,11 +30,17 @@ def generate_anchor_from_path(path):
def
replace_link
(
match
,
path
):
def
replace_link
(
match
,
path
):
link
=
match
.
group
(
1
)
title
=
match
.
group
(
1
)
link
=
match
.
group
(
2
)
# Not a relative link
if
link
.
startswith
(
'http'
):
return
match
.
group
(
0
)
if
link
.
endswith
(
'/'
):
if
link
.
endswith
(
'/'
):
link
=
link
[
0
:
-
1
]
+
'.md'
link
=
link
[
0
:
-
1
]
+
'.md'
return
'
(#{})'
.
format
(
generate_anchor_from_path
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
path
),
link
))))
return
'
[{}](#{})'
.
format
(
title
,
generate_anchor_from_path
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
path
),
link
))))
# Concatenates Markdown files to a single file.
# Concatenates Markdown files to a single file.
...
@@ -52,8 +58,7 @@ def concatenate(lang, docs_path, single_page_file, nav):
...
@@ -52,8 +58,7 @@ def concatenate(lang, docs_path, single_page_file, nav):
logging
.
debug
(
'Concatenating: '
+
', '
.
join
(
files_to_concatenate
))
logging
.
debug
(
'Concatenating: '
+
', '
.
join
(
files_to_concatenate
))
assert
files_count
>
0
,
f
'Empty single-page for
{
lang
}
'
assert
files_count
>
0
,
f
'Empty single-page for
{
lang
}
'
# (../anything) or (../anything#anchor) or (xyz-abc.md) or (xyz-abc.md#anchor)
link_regexp
=
re
.
compile
(
r
'(\[[^\]]+\])\(([^)#]+)(?:#[^\)]+)?\)'
)
relative_link_regexp
=
re
.
compile
(
r
'\((\.\./[^)#]+|[\w\-]+\.md)(?:#[^\)]*)?\)'
)
for
path
in
files_to_concatenate
:
for
path
in
files_to_concatenate
:
try
:
try
:
...
@@ -75,9 +80,9 @@ def concatenate(lang, docs_path, single_page_file, nav):
...
@@ -75,9 +80,9 @@ def concatenate(lang, docs_path, single_page_file, nav):
# Replace links within the docs.
# Replace links within the docs.
if
re
.
search
(
relative_
link_regexp
,
line
):
if
re
.
search
(
link_regexp
,
line
):
line
=
re
.
sub
(
line
=
re
.
sub
(
relative_
link_regexp
,
link_regexp
,
lambda
match
:
replace_link
(
match
,
path
),
lambda
match
:
replace_link
(
match
,
path
),
line
)
line
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录