Skip to content

Commit

Permalink
Update docs so that we add links between more code snippets mentionin…
Browse files Browse the repository at this point in the history
…g a function and the actual function
  • Loading branch information
gfwilliams committed Oct 25, 2024
1 parent a99791f commit dd9d49c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ void jswrap_ble_setTxPower(JsVarInt pwr) {
}
**THIS IS DEPRECATED** - please use `NRF.setConnectionInterval` for peripheral
and `NRF.connect(addr, options)`/`BluetoothRemoteGATTServer.connect(options)`
and `NRF.connect(address, options)`/`BluetoothRemoteGATTServer.connect(options)`
for central connections.
This sets the connection parameters - these affect the transfer speed and power
Expand Down Expand Up @@ -3831,7 +3831,7 @@ JsVar *jswrap_ble_startBonding(bool forceRePair) {
"ifdef" : "NRF52_SERIES"
}
A Web Bluetooth-style device - you can request one using
`NRF.requestDevice(address)`
`NRF.requestDevice(options)`
For example:
Expand Down
15 changes: 10 additions & 5 deletions scripts/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ def htmlify(d,current):
end = d.find("</code>", idx)
while idx>=0 and end>idx:
codeBlock = d[idx+6:end]
# search for known links in code
if codeBlock[-2:]=="()" and codeBlock[:-2] in links:
codeBlock = "<a href=\"#"+links[codeBlock[:-2]]+"\">"+codeBlock+"</a>";
# search for known links in code (any function call regardless of param names)
m = re.match(r"^([A-Za-z0-9.]+)\([A-Za-z0-9,\.]*\)$", codeBlock)
if m:
link = m.groups()[0]
if link+"()" in links: # 'and link!=current' would stop a function linking to itself
codeBlock = "<a href=\"#"+links[link+"()"]+"\">"+codeBlock+"</a>";
elif codeBlock in links:
codeBlock = "<a href=\"#"+links[codeBlock]+"\">"+codeBlock+"</a>";
# ensure multi-line code is handled correctly
Expand Down Expand Up @@ -281,8 +284,10 @@ def insert_mdn_link(jsondata):
def add_link(jsondata):
if not "no_create_links" in jsondata:
link = get_prefixed_name(jsondata);
if link!="global":
links[link] = get_link(jsondata)
url = get_link(jsondata)
links[link] = url
if common.is_function(jsondata):
links[link+"()"] = url
jsondatas = sorted(jsondatas, key=lambda s: common.get_name_or_space(s).lower())

html(' <div id="contents">')
Expand Down
2 changes: 1 addition & 1 deletion scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def is_property(jsondata):
return jsondata["type"]=="property" or jsondata["type"]=="staticproperty" or jsondata["type"]=="variable"

def is_function(jsondata):
return jsondata["type"]=="function" or jsondata["type"]=="method"
return jsondata["type"]=="method" or jsondata["type"]=="staticmethod" or jsondata["type"]=="function"

def get_prefix_name(jsondata):
if jsondata["type"]=="event": return "event"
Expand Down

0 comments on commit dd9d49c

Please sign in to comment.