Skip to content

Commit 39d4085

Browse files
author
Amanda Butler
authored
Merge branch 'development' into us_ticker_freq_fix
2 parents 7bcac4d + f2e3acb commit 39d4085

File tree

697 files changed

+13687
-17566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

697 files changed

+13687
-17566
lines changed

.circleci/config.yml

Lines changed: 129 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,144 @@
1-
version: 2
1+
version: 2.1
22

3-
jobs:
4-
build:
3+
references:
4+
workspace_root: &workspace_root
5+
/tmp/workspace
6+
attach_workspace: &attach_workspace
7+
attach_workspace:
8+
at: *workspace_root
9+
10+
executors:
11+
doc_builder:
512
docker:
613
- image: mbed/doc_builder:latest
714
auth:
815
username: $DOCKER_USER
916
password: $DOCKER_PASS
1017

18+
commands:
19+
setup_aws_credentials:
20+
description: "Setup AWS credentials"
1121
steps:
12-
- checkout
22+
- run:
23+
name: Write credentials to ~/.aws/credentials
24+
command: |
25+
mkdir ~/.aws
26+
echo -e "[default]\naws_access_key_id=$AWS_PROD_ACCESS_KEY_ID\naws_secret_access_key=$AWS_PROD_SECRET_KEY\n" > ~/.aws/credentials
27+
write_env_variables:
28+
description: "Write ENV variables"
29+
steps:
30+
- run:
31+
command: |
32+
echo "export CIRCLE_BRANCH_NO_SLASH=$(echo $CIRCLE_BRANCH|sed 's/\//-/')" >> /tmp/env
33+
1334
35+
jobs:
36+
build:
37+
executor: doc_builder
38+
steps:
39+
- checkout
40+
- setup_aws_credentials
41+
- write_env_variables
42+
- run:
43+
name: Validate redirects
44+
command: |
45+
if [ -f "$HOME/project/redirects.json" ]; then
46+
python -mjson.tool "$HOME/project/redirects.json" > /dev/null
47+
fi
1448
- run:
1549
name: Validate and build documentation
1650
command: |
17-
docbuilder build os-docs /tmp/artifacts --path ~/project/docs.json --github_token "$GITHUB_TOKEN"
51+
source /tmp/env
52+
docbuilder build $CIRCLE_BRANCH_NO_SLASH /tmp/workspace/artifacts --path ~/project/docs.json --github_token "$GITHUB_TOKEN"
53+
- persist_to_workspace:
54+
root: *workspace_root
55+
paths:
56+
- artifacts
57+
58+
publish_to_s3:
59+
executor: doc_builder
60+
steps:
61+
- setup_aws_credentials
62+
- write_env_variables
63+
- *attach_workspace
1864
- run:
19-
name: Move images
65+
name: Upload documentation to s3
2066
command: |
21-
cp -R ~/project/docs/images /tmp/artifacts/
67+
source /tmp/env
68+
docbuilder publish /tmp/workspace/artifacts/$CIRCLE_BRANCH_NO_SLASH iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/$CIRCLE_SHA1
69+
70+
push_redirects_to_s3:
71+
executor: doc_builder
72+
steps:
73+
- checkout
74+
- setup_aws_credentials
75+
- write_env_variables
76+
- *attach_workspace
77+
- run:
78+
name: Upload redirects.json to s3
79+
command: |
80+
source /tmp/env
81+
docbuilder upload_file ~/project/redirects.json iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/redirects.json
82+
83+
zip_documentation:
84+
machine: true
85+
steps:
86+
- *attach_workspace
87+
- run:
88+
name: Zip built documentation
89+
command: |
90+
cd /tmp/workspace/artifacts
91+
zip -r /tmp/workspace/docs.zip .
92+
- store_artifacts:
93+
path: /tmp/workspace/docs.zip
94+
95+
list_pages:
96+
machine: true
97+
steps:
98+
- write_env_variables
99+
- *attach_workspace
100+
- run:
101+
name: List all built docs pages
102+
command: |
103+
source /tmp/env
104+
cd /tmp/workspace/artifacts/$CIRCLE_BRANCH_NO_SLASH
105+
find -maxdepth 2 -type f -name '*.html' -not -path "*-doxy/*" -printf '%P\n' > /tmp/workspace/page_list.txt
22106
- store_artifacts:
23-
path: /tmp/artifacts
24-
destination: docs
107+
path: /tmp/workspace/page_list.txt
108+
109+
make_live:
110+
executor: doc_builder
111+
steps:
112+
- setup_aws_credentials
113+
- write_env_variables
114+
- run:
115+
name: Update live version on s3
116+
command: |
117+
source /tmp/env
118+
docbuilder set_live_version iot-doc-builds $CIRCLE_PROJECT_REPONAME/$CIRCLE_BRANCH_NO_SLASH/$CIRCLE_SHA1
119+
120+
workflows:
121+
version: 2
122+
build-publish-zip-deploy:
123+
jobs:
124+
- build
125+
- publish_to_s3:
126+
requires:
127+
- build
128+
- push_redirects_to_s3:
129+
requires:
130+
- build
131+
- zip_documentation:
132+
requires:
133+
- build
134+
- list_pages:
135+
requires:
136+
- build
137+
# - await_approval:
138+
# type: approval
139+
# requires:
140+
# - publish_to_s3
141+
- make_live:
142+
requires:
143+
# - await_approval
144+
- publish_to_s3

.github/ISSUE_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Docs issue template
2+
3+
## Page link
4+
5+
## Expected to find...
6+
7+
## Found

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

check_tools/config-update.py

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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+
32+
import sys, os
33+
import re
34+
import subprocess
35+
36+
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+
"""
45+
for i in range(0, len(l), 2):
46+
yield l[i:i + 2]
47+
48+
def is_string(line):
49+
""" Determine if the provided string contains
50+
alphabetical characters (case insensitive)
51+
Args:
52+
line - string to scan
53+
54+
Returns:
55+
Match object if the string contains [a-z], else None
56+
"""
57+
regexp = re.compile(r'[a-z]', re.IGNORECASE)
58+
return regexp.search(line)
59+
60+
def main(file):
61+
file_h = open(file, 'r+')
62+
file = file_h.read()
63+
64+
# Collect indices of markdown code block ticks, split into start,end pairs
65+
# with `split_into_pairs` below. Collect the config parameter prefix used in
66+
# the current block if viable and replace the contents with the output of
67+
# the Mbed CLI config verbose list command.
68+
snippet_indices = [m.start() for m in re.finditer('```', file)]
69+
70+
blocks = {}
71+
for i in range(0, int(len(snippet_indices) / 2)):
72+
# Need to rerun on every loop as the indices change each iteration
73+
snippet_indices = [m.start() for m in re.finditer('```', file)]
74+
ranges = list(split_into_pairs(snippet_indices))
75+
start = ranges[i][0]
76+
end = ranges[i][1]
77+
78+
try:
79+
blocks[i] = file[start : end + 3]
80+
if ('Name: ' in blocks[i]):
81+
lib = blocks[i].split('Name: ')[1].split('.')[0]
82+
print("================= %s =================" % lib)
83+
out = str(subprocess.check_output(["mbed", "compile", "--config", "-v", "--prefix", lib]))
84+
85+
# Some APIs break config options into logical blocks in their config files.
86+
# If a tag is applied to a parameter block, only display parameter names that contain that tag
87+
# For example:
88+
# ```heap
89+
# mbed-mesh-api.heap-size
90+
# ...
91+
# mbed-mesh-api.heap-stat-info
92+
# ..
93+
# ......
94+
# ```
95+
#
96+
# On encountering a block with a tag, collect the common parameter token,
97+
# and split the configuration list output into its components.
98+
# Collect tag (if present), split <TAG> from ```<TAG> at current index
99+
# Check with regex for string to cover for potential trailing whitespaces
100+
tag = file[start : file.find('\n', start)].split('`')[-1]
101+
if is_string(tag):
102+
print("\t------- Tag: %s -------" % tag)
103+
104+
start_of_config_block = file.find('Name:', start)
105+
updated_config = str(file[ : start_of_config_block])
106+
for line in out.splitlines():
107+
if 'Name' in line and tag in line:
108+
updated_config += line
109+
110+
# Collect all text until next parameter name. If there's no following 'Name:' token, its the last
111+
# config option, match to 'Macros' instead to termiante the block. Offset starting index to avoid finding
112+
# the current line's 'Name:' token.
113+
eol = out.find('\n', out.find(line))
114+
if out.find('Name:', out.find(line) + len('Name:')) > 0:
115+
updated_config += out[eol : out.find('Name:', out.find(line) + len('Name:'))]
116+
else:
117+
updated_config += out[eol : out.find('Macros', out.find(line))]
118+
119+
updated_config += str(file[end:])
120+
else:
121+
updated_config = str(file[:start+4] + out[:out.index("Macros") - 1] + file[end:])
122+
123+
file = updated_config
124+
125+
# Originally added for debugging purposes, catch and display exceptions before
126+
# continuing without exiting to provide a complete list of errors found
127+
except Exception as e:
128+
print("Error")
129+
print(e)
130+
print("____________________")
131+
exc_type, exc_obj, exc_tb = sys.exc_info()
132+
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
133+
print(exc_type, fname, exc_tb.tb_lineno)
134+
pass
135+
136+
file_h.truncate(0)
137+
file_h.seek(0)
138+
file_h.write(file)
139+
file_h.close()
140+
141+
if __name__ == '__main__':
142+
if (len(sys.argv) < 2):
143+
path = '../docs/reference/configuration'
144+
else:
145+
path = sys.argv[1]
146+
147+
if (path == '-h' or path == '--help'):
148+
print("By default the script runs out of the docs tools directory and iterates through reference/configuration.\n"
149+
"You may pass in a directory path that will run on all files contained within, or a single file path optionally.")
150+
exit(0)
151+
152+
if (os.path.isfile(path)):
153+
main(path)
154+
elif (os.path.isdir(path)):
155+
for doc in os.listdir(path):
156+
if (doc != 'configuration.md'):
157+
print('_____ %s _____' % os.path.join(path, doc))
158+
main(os.path.join(path, doc))
159+
else:
160+
print("Please provide a valid file or directory path")

0 commit comments

Comments
 (0)