Skip to content

Commit 4a657f1

Browse files
author
Amanda Butler
authored
Merge pull request #980 from kegilbert/configupdate-docs
Add improved docs and license to config-update utility
2 parents f3e33f6 + e9a1f8e commit 4a657f1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

check_tools/config-update.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,58 @@
1+
#! /usr/bin/env python
2+
"""
3+
mbed SDK
4+
Copyright (c) 2019 ARM Limited
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
LIBRARIES BUILD
15+
"""
16+
17+
# Script to automatically update the configuration parameters list in
18+
# each configuration doc page with the output from `mbed compile --config -v`
19+
# for the page's appropriate prefix.
20+
#
21+
# By default, when run from the check_tools directory, the script runs
22+
# through each Markdown file in `docs/reference/configuration/`. An
23+
# optional file or directory path may be passed in a parameter to run the
24+
# script on a specific file or directroy outside the default path.
25+
#
26+
# Note that you need to run this with a local copy of whichever version of
27+
# Mbed OS you wish to update the configuration parameters with.
28+
#
29+
# You can run this script with:
30+
# python config-update.py <OPTIONAL FILE/DIR PATH>
31+
132
import sys, os
233
import re
334
import subprocess
435

536
def split_into_pairs(l):
37+
""" Split the provided list into a, b pairs.
38+
[1, 2, 3, 4] -> [[1, 2], [3, 4]]
39+
Args:
40+
l - list of values to be split
41+
42+
Returns:
43+
List of split pairs
44+
"""
645
for i in range(0, len(l), 2):
746
yield l[i:i + 2]
847

948
def main(file):
1049
file_h = open(file, 'r+')
1150
file = file_h.read()
51+
52+
# Collect indices of markdown code block ticks, split into start,end pairs
53+
# with `split_into_pairs` below. Collect the config parameter prefix used in
54+
# the current block if viable and replace the contents with the output of
55+
# the Mbed CLI config verbose list command.
1256
snippet_indices = [m.start() for m in re.finditer('```', file)]
1357

1458
blocks = {}

0 commit comments

Comments
 (0)