Skip to content

Commit 421a143

Browse files
Add function_aliases frontmatter and auto-link them
Ticket: ENT-14145
1 parent 05c5733 commit 421a143

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

content/reference/functions/findfiles_up.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: default
33
title: findfiles_up
4+
function_aliases: search_up
45
aliases:
56
- "/reference-functions-findfiles_up.html"
67
---

generator/_references.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,4 @@
7171
[getpwuid()]: https://linux.die.net/man/3/getpwuid
7272
[getpwnam()]: https://linux.die.net/man/3/getpwnam
7373
[select()]: https://linux.die.net/man/3/select
74-
[search_up()]: /reference/functions/findfiles_up
7574
[High availability]: /examples/tutorials/high-availability/ "CFEngine High availability overview"

generator/_scripts/cfdoc_linkresolver.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def parseMarkdownForAnchors(file_name, config):
138138
current_title = ""
139139
header_list = []
140140
keywords = []
141+
function_aliases = []
141142

142143
in_pre = False
143144
for line in lines:
@@ -155,6 +156,11 @@ def parseMarkdownForAnchors(file_name, config):
155156
current_title = line.split("title: ")
156157
current_title = current_title[1].rstrip().rstrip('"')
157158
current_title = current_title.lstrip().lstrip('"')
159+
elif line.startswith("function_aliases:"):
160+
function_aliases = (
161+
line.split("function_aliases:")[1].strip().lstrip("[").rstrip("]")
162+
)
163+
function_aliases = function_aliases.split(",")
158164
elif line.find("alias:") == 0:
159165
current_file_name = line.split("alias: ")
160166
current_file_name = current_file_name[1].rstrip()
@@ -195,6 +201,19 @@ def parseMarkdownForAnchors(file_name, config):
195201
current_file_name + ' "' + current_title + '"',
196202
config,
197203
)
204+
205+
# register function aliases in the Links map,
206+
# so they can be auto-linked to the function reference page
207+
for function_alias in function_aliases:
208+
function_alias = function_alias.lstrip().rstrip()
209+
if function_alias == "":
210+
continue
211+
addLinkToMap(
212+
function_alias,
213+
function_alias,
214+
current_file_name + ' "' + current_title + '"',
215+
config,
216+
)
198217
for header in header_list:
199218
if header == "":
200219
continue

0 commit comments

Comments
 (0)