From 9faa4af1c3cf0665ede20de8d98005ef9016b792 Mon Sep 17 00:00:00 2001 From: Eric Wolfe Date: Wed, 21 Dec 2016 10:22:13 -0800 Subject: [ios] Add inline examples in documentation (#7337) --- platform/ios/scripts/add-examples-to-docs.js | 65 ++++++++++++++++++++++++++++ platform/ios/scripts/document.sh | 5 +++ 2 files changed, 70 insertions(+) create mode 100644 platform/ios/scripts/add-examples-to-docs.js (limited to 'platform/ios/scripts') diff --git a/platform/ios/scripts/add-examples-to-docs.js b/platform/ios/scripts/add-examples-to-docs.js new file mode 100644 index 0000000000..7be755e2c6 --- /dev/null +++ b/platform/ios/scripts/add-examples-to-docs.js @@ -0,0 +1,65 @@ +'use strict'; + +const fs = require('fs'); + +const examples = fs.readFileSync(`${__dirname}/../test/MGLDocumentationExampleTests.swift`, 'utf8'); + +// Regex extracts the following block +// /*---BEGIN EXAMPLE: MGLStyleSource---*/ +// /* Frontmatter to describe the example */ +// let sampleCode: String? +// /*---END EXAMPLE---*/ +// +// into the following regex groups: +// 1 (token): " MGLStyleSource" +// 2 (frontmatter): "/* Frontmatter to describe the example */" +// 3 (sample code): "let sampleCode: String?" +const exampleRegex = /\/\*---BEGIN EXAMPLE:(.*)---\*\/\s*(\/\*+[\s\S]*?\*+\/)?([\s\S]*?)\/\*---END EXAMPLE---\*\//gm; + +var path = `${process.env.TARGET_BUILD_DIR}/${process.env.PUBLIC_HEADERS_FOLDER_PATH}`; + +console.log("Installing examples..."); + +var match; +while ((match = exampleRegex.exec(examples)) !== null) { + const token = match[1].trim(); + const className = token.split('.')[0]; + + const frontmatter = (match[2] || '') + .replace(/\/\*+/g, '') // Remove block comment /** + .replace(/\*+\//g, '') // Remove block comment end */ + .trim() + .replace(/\n {8,9}/g, '\n'); // Remove leading whitespace (8-9 spaces incl block comment) + + const exampleCode = match[3] + .trim() + .replace(/\n {8}/g, '\n'); // Remove leading whitespace (8 spaces) + + // Generate example text + var exampleText = "### Example\n\n"; + if (frontmatter.length > 0) { + exampleText += `${frontmatter}\n\n`; + } + exampleText += "```swift\n" + exampleCode + "\n```"; + exampleText = exampleText.replace(/\n/g, '\n '); + + const placeholderRegex = new RegExp(``); + + // check if file exists at path + const filename = `${path}/${className}.h`; + + if (fs.existsSync(filename)) { + const file = fs.readFileSync(filename, 'utf8'); + // Check for example placeholder in file & update file if found + if (placeholderRegex.test(file)) { + console.log("Updating example:", filename); + fs.writeFileSync(filename, file.replace(placeholderRegex, exampleText)); + } else if (file.indexOf(exampleText) === -1) { + console.log(`Placeholder "${token}" missing:`, filename); + } else { + console.log(`Example "${token}" already replaced.`); + } + } else if (token !== "ExampleToken") { + console.log("Error file doesn't exist:", filename); + } +} diff --git a/platform/ios/scripts/document.sh b/platform/ios/scripts/document.sh index fddf5abb0f..78eb5121eb 100755 --- a/platform/ios/scripts/document.sh +++ b/platform/ios/scripts/document.sh @@ -35,11 +35,16 @@ cp platform/ios/screenshot.png "${OUTPUT}" DEFAULT_THEME="platform/darwin/docs/theme" THEME=${JAZZY_THEME:-$DEFAULT_THEME} +DEFAULT_FRAMEWORK_PATH="build/ios/pkg/dynamic/Mapbox.framework" +FRAMEWORK_PATH=${FRAMEWORK_PATH:-$DEFAULT_FRAMEWORK_PATH} + jazzy \ --config platform/ios/jazzy.yml \ --sdk iphonesimulator \ --github-file-prefix https://github.com/mapbox/mapbox-gl-native/tree/${BRANCH} \ --module-version ${SHORT_VERSION} \ + --framework-root ${FRAMEWORK_PATH} \ + --umbrella-header "${FRAMEWORK_PATH}/Headers/Mapbox.h" \ --readme ${README} \ --documentation="platform/ios/docs/Info.plist Keys.md" \ --root-url https://www.mapbox.com/ios-sdk/api/${RELEASE_VERSION}/ \ -- cgit v1.2.1 From 01717af59f5700cc22df17485bf2ba56eab65968 Mon Sep 17 00:00:00 2001 From: Eric Wolfe Date: Tue, 3 Jan 2017 14:40:14 -0800 Subject: [ios] Adds guides to documentation sidebar (#7488) Initial set of guides focused on runtime styling --- platform/ios/scripts/document.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'platform/ios/scripts') diff --git a/platform/ios/scripts/document.sh b/platform/ios/scripts/document.sh index 78eb5121eb..634f4de5dc 100755 --- a/platform/ios/scripts/document.sh +++ b/platform/ios/scripts/document.sh @@ -30,7 +30,7 @@ sed -n -e '/^## /{' -e ':a' -e 'n' -e '/^## /q' -e 'p' -e 'ba' -e '}' platform/i rm -rf ${OUTPUT} mkdir -p ${OUTPUT} -cp platform/ios/screenshot.png "${OUTPUT}" +cp -r platform/ios/docs/img "${OUTPUT}/img" DEFAULT_THEME="platform/darwin/docs/theme" THEME=${JAZZY_THEME:-$DEFAULT_THEME} @@ -46,7 +46,7 @@ jazzy \ --framework-root ${FRAMEWORK_PATH} \ --umbrella-header "${FRAMEWORK_PATH}/Headers/Mapbox.h" \ --readme ${README} \ - --documentation="platform/ios/docs/Info.plist Keys.md" \ + --documentation="platform/ios/docs/guides/*.md" \ --root-url https://www.mapbox.com/ios-sdk/api/${RELEASE_VERSION}/ \ --theme ${THEME} \ --output ${OUTPUT} -- cgit v1.2.1 From 50ae3eb3c0985567a0f86d08337d7cb8bed79a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 4 Jan 2017 12:19:31 -0800 Subject: [ios, macos] Insert example code in original headers (#7569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ios, macos] Removed extraneous code fences * [ios] Streamlined example delimiters Use test method names as names of example blocks and test method documentation comments as front matter for examples. Set off example blocks using a syntax similar to playground markup syntax. Avoid hard-coding indentation levels. Trigger Xcode build error when an error occurs in the script. * [ios] Removed platform-specific code from examples * [ios] Fixed logic error The comment said 200 while the code said 1,500. * [ios] Formalize build phase input * [ios] Insert examples into original source documentation Rewrote the example code insertion script to work on the original source files and overwrite any existing code examples on the same symbols. The script uses SourceKitten to find the documentation comment for the symbol named by the test method. Replaced the Run Script build phase that runs the example code insertion script with a make rule that runs the same script. Inlined skeleton examples minus the contents of the code blocks. * [ios] Fixed syntax error * [ios] Ran ios-add-examples-to-docs * [ios] Avoid touching unchanged headers * [ios] Refactored example insertion script * [ios] Point jazzy at original sources * [ios] Invoke SourceKitten only once * [ios] Look for methods as well as properties * [ios] Thoroughly search for code blocks in doc comments Refactored the example code insertion script to index test methods by their names, then recursively search the SourceKitten output for documentation comments that contain Swift code blocks, replacing each code block with the associated test method body. * [ios, macos] Enabled example insertion for macOS The example code insertion script is now platform-agnostic. * [ios, macos] Fixed documentation example tests Set the map view’s style to a minimal local JSON file. Wait for the style to finish loading before running each test. Corrected CGVector type. * [ios, macos] Dry run mode The output of this mode isn’t a good indicator of whether any files would’ve needed to be changed, because the presence of a conditional compilation block in one of the test methods means this script would always change and revert the corresponding comment. * [ios] Fixed test failure The iOS implementation of MGLMapView tries to show the Streets style by default even if no access token has been set. Avoid a race condition and frequent test failure by specifying the minimal style on initialization. * [ios, macos] Ensure SourceKitten is installed before inserting example code * [ios, macos] Tear down map view after each test Keep map views from previous tests from hanging around, potentially obscuring the result of a subsequent test. Set the access token to a bogus token upfront for all style layer tests. Unified MGLStyle usage within MGLStyleTests. * [ios, macos] Reinsert examples after generating runtime styling headers --- platform/ios/scripts/add-examples-to-docs.js | 65 ---------------------------- platform/ios/scripts/document.sh | 5 --- 2 files changed, 70 deletions(-) delete mode 100644 platform/ios/scripts/add-examples-to-docs.js (limited to 'platform/ios/scripts') diff --git a/platform/ios/scripts/add-examples-to-docs.js b/platform/ios/scripts/add-examples-to-docs.js deleted file mode 100644 index 7be755e2c6..0000000000 --- a/platform/ios/scripts/add-examples-to-docs.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -const fs = require('fs'); - -const examples = fs.readFileSync(`${__dirname}/../test/MGLDocumentationExampleTests.swift`, 'utf8'); - -// Regex extracts the following block -// /*---BEGIN EXAMPLE: MGLStyleSource---*/ -// /* Frontmatter to describe the example */ -// let sampleCode: String? -// /*---END EXAMPLE---*/ -// -// into the following regex groups: -// 1 (token): " MGLStyleSource" -// 2 (frontmatter): "/* Frontmatter to describe the example */" -// 3 (sample code): "let sampleCode: String?" -const exampleRegex = /\/\*---BEGIN EXAMPLE:(.*)---\*\/\s*(\/\*+[\s\S]*?\*+\/)?([\s\S]*?)\/\*---END EXAMPLE---\*\//gm; - -var path = `${process.env.TARGET_BUILD_DIR}/${process.env.PUBLIC_HEADERS_FOLDER_PATH}`; - -console.log("Installing examples..."); - -var match; -while ((match = exampleRegex.exec(examples)) !== null) { - const token = match[1].trim(); - const className = token.split('.')[0]; - - const frontmatter = (match[2] || '') - .replace(/\/\*+/g, '') // Remove block comment /** - .replace(/\*+\//g, '') // Remove block comment end */ - .trim() - .replace(/\n {8,9}/g, '\n'); // Remove leading whitespace (8-9 spaces incl block comment) - - const exampleCode = match[3] - .trim() - .replace(/\n {8}/g, '\n'); // Remove leading whitespace (8 spaces) - - // Generate example text - var exampleText = "### Example\n\n"; - if (frontmatter.length > 0) { - exampleText += `${frontmatter}\n\n`; - } - exampleText += "```swift\n" + exampleCode + "\n```"; - exampleText = exampleText.replace(/\n/g, '\n '); - - const placeholderRegex = new RegExp(``); - - // check if file exists at path - const filename = `${path}/${className}.h`; - - if (fs.existsSync(filename)) { - const file = fs.readFileSync(filename, 'utf8'); - // Check for example placeholder in file & update file if found - if (placeholderRegex.test(file)) { - console.log("Updating example:", filename); - fs.writeFileSync(filename, file.replace(placeholderRegex, exampleText)); - } else if (file.indexOf(exampleText) === -1) { - console.log(`Placeholder "${token}" missing:`, filename); - } else { - console.log(`Example "${token}" already replaced.`); - } - } else if (token !== "ExampleToken") { - console.log("Error file doesn't exist:", filename); - } -} diff --git a/platform/ios/scripts/document.sh b/platform/ios/scripts/document.sh index 634f4de5dc..ec349d592d 100755 --- a/platform/ios/scripts/document.sh +++ b/platform/ios/scripts/document.sh @@ -35,16 +35,11 @@ cp -r platform/ios/docs/img "${OUTPUT}/img" DEFAULT_THEME="platform/darwin/docs/theme" THEME=${JAZZY_THEME:-$DEFAULT_THEME} -DEFAULT_FRAMEWORK_PATH="build/ios/pkg/dynamic/Mapbox.framework" -FRAMEWORK_PATH=${FRAMEWORK_PATH:-$DEFAULT_FRAMEWORK_PATH} - jazzy \ --config platform/ios/jazzy.yml \ --sdk iphonesimulator \ --github-file-prefix https://github.com/mapbox/mapbox-gl-native/tree/${BRANCH} \ --module-version ${SHORT_VERSION} \ - --framework-root ${FRAMEWORK_PATH} \ - --umbrella-header "${FRAMEWORK_PATH}/Headers/Mapbox.h" \ --readme ${README} \ --documentation="platform/ios/docs/guides/*.md" \ --root-url https://www.mapbox.com/ios-sdk/api/${RELEASE_VERSION}/ \ -- cgit v1.2.1 From 0fac9d5674453f587a4c86f71b06da668f8cae27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 23 Dec 2016 17:47:51 -0800 Subject: [ios, macos] Added guide for working with GeoJSON --- platform/ios/scripts/document.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/ios/scripts') diff --git a/platform/ios/scripts/document.sh b/platform/ios/scripts/document.sh index ec349d592d..d66742a33f 100755 --- a/platform/ios/scripts/document.sh +++ b/platform/ios/scripts/document.sh @@ -41,7 +41,7 @@ jazzy \ --github-file-prefix https://github.com/mapbox/mapbox-gl-native/tree/${BRANCH} \ --module-version ${SHORT_VERSION} \ --readme ${README} \ - --documentation="platform/ios/docs/guides/*.md" \ + --documentation="platform/{darwin,ios}/docs/guides/*.md" \ --root-url https://www.mapbox.com/ios-sdk/api/${RELEASE_VERSION}/ \ --theme ${THEME} \ --output ${OUTPUT} -- cgit v1.2.1 From 4adcdac7b5eeca79411e877ef11d5248f4107963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 15 Jan 2017 13:18:21 -0800 Subject: [macos] Upgrade macOS deployment and distribution (#7649) * [macos] Updated deployment scripts Ported fixes from #6581 and #6740. * [macos] Acknowledge AppleScript support * [macos] Prepared for published documentation Also added link to Dash docset. * [macos] Added CocoaPods podspecs Ported from #5653. * [macos] Rewrote readme; updated screenshot * [macos] Include setup instructions in standalone docs --- platform/ios/scripts/deploy-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/ios/scripts') diff --git a/platform/ios/scripts/deploy-packages.sh b/platform/ios/scripts/deploy-packages.sh index 8ad5e7abb1..2265afdba6 100755 --- a/platform/ios/scripts/deploy-packages.sh +++ b/platform/ios/scripts/deploy-packages.sh @@ -44,7 +44,7 @@ buildPackageStyle() { --tag "ios-v${PUBLISH_VERSION}" \ --name ${file_name} \ --file "${BINARY_DIRECTORY}/${file_name}" > /dev/null - fi + fi } export TRAVIS_REPO_SLUG=mapbox-gl-native -- cgit v1.2.1