Skip to content

Commit

Permalink
Consolidate developer documentation in mdBook docs (#3115)
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Jan 6, 2025
1 parent 660f78c commit c7e6b0c
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 131 deletions.
6 changes: 5 additions & 1 deletion docs/mdbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Build Locally

Get the `mdbook` utility, see https://rust-lang.github.io/mdBook/guide/installation.html
Get the `mdbook` utility as well as [`mdbook-alerts`](https://github.com/lambdalisue/rs-mdbook-alerts), see https://rust-lang.github.io/mdBook/guide/installation.html

```
cargo install mdbook mdbook-alerts
```

Run

Expand Down
4 changes: 3 additions & 1 deletion docs/mdbook/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ authors = ["MapLibre Contributors"]
language = "en"
multilingual = false
src = "src"
title = "MapLibre Native Documentation"
title = "MapLibre Native Developer Documentation"

[output.html]
additional-css = ["diff.css"]

[preprocessor.alerts]
24 changes: 17 additions & 7 deletions docs/mdbook/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

[Introduction](./introduction.md)

- [Platforms](./platforms.md)

- [Android](./android/README.md)
- [Tests](./android/android-tests.md)
- [Documentation](./android/android-documentation.md)

- [iOS](./ios/README.md)
- [Tests](ios/ios-tests.md)
- [Documentation](ios/ios-documentation.md)

- [Design](./design/README.md)
- [Ten Thousand Foot View](design/ten-thousand-foot-view.md)
- [Coordinate System](design/coordinate-system.md)
- [Expressions](design/expressions.md)
- [Architectural Problems and Recommendations](design/archictural-problems-and-recommendations.md)
- [Android Map Rendering Data Flow](design/android-map-rendering-data-flow.md)
- [Geometry Tile Worker](design/geometry-tile-worker.md)
- [Ten Thousand Foot View](design/ten-thousand-foot-view.md)
- [Coordinate System](design/coordinate-system.md)
- [Expressions](design/expressions.md)
- [Architectural Problems and Recommendations](design/archictural-problems-and-recommendations.md)
- [Android Map Rendering Data Flow](design/android-map-rendering-data-flow.md)
- [Geometry Tile Worker](design/geometry-tile-worker.md)

- [Profiling applications that use MapLibre Native](./profiling/README.md)
- [Tracy profiling](./profiling/tracy-profiling.md)
- [Tracy profiling](./profiling/tracy-profiling.md)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Developing - MapLibre Native for Android
# MapLibre Android Developer Guide

These instructions are for developers interested in making code-level contributions to MapLibre Native for Android.

Expand Down Expand Up @@ -33,34 +33,6 @@ Run the configuration for the `MapLibreAndroidTestApp` module and select a devic
<img src="https://github.com/maplibre/maplibre-native/assets/649392/5494925e-8cbb-4d5d-8033-8a2f141ede3c" alt="Android TestApp menu" width="15%"> <img src="https://github.com/maplibre/maplibre-native/assets/649392/f169db51-615d-4fca-b297-ac6197bec674" alt="Android TestApp showing Demotiles" width="15%">
</p>

## Render Tests

To run the render tests for Android, run the configuration for the `androidRenderTest.app` module.

More information on working on the render tests can be found [in the wiki](https://github.com/maplibre/maplibre-native/wiki/Working-on-Android-Render-Tests).

## Instrumentation Tests

To run the instrumentation tests, choose the "Instrumentation Tests" run configuration.

Your device needs remain unlocked for the duration of the tests.

## C++ Unit Tests

There is a separate Gradle project that contains a test app which runs the C++ Unit Tests. It does not depend on the Android platform implementations.

You can find the project in `test/android.` You can open this project in Android Studio and run the C++ Tests on an Android device or Simulator.

To run a particular set of tests you can modify the `--gtest_filter` flag in `platform/android/src/test/test_runner.cpp`. See the [GoogleTest documentation](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) for details how to use this flag.

### AWS Device Farm

The instrumentation tests and C++ unit tests are running on AWS Device Farm. To see the results and the logs, go to:

https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs

You can log in with the `maplibre` alias, with `maplibre` as username and `maplibre` as password (this is a read-only account).

## Kotlin

All new code should be written in [Kotlin](https://kotlinlang.org/).
Expand Down Expand Up @@ -91,11 +63,4 @@ To run the benchmarks (for Android) include the following line on a PR comment:

## Profiling

[maplibre-native/docs/mdbook](https://maplibre.org/maplibre-native/docs/book/) describes how Tracy can be used for profiling.


## Documentation

We use Dokka for the API documentation.

The documentation site with examples uses MkDocs along with Material for MkDocs. For more information on how to work on the examples, see [`docs/README.md`](./docs/REAME.md`).
See [Tracy Profiling](/profiling/tracy-profiling.md) to understand how Tracy can be used for profiling.
49 changes: 49 additions & 0 deletions docs/mdbook/src/android/android-documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Documentation for MapLibre Android

## API Documentation

We use Dokka for the MapLibre Android API documentation. The live documentation site can be found [here](https://maplibre.org/maplibre-native/android/api/).

## Examples Documentation

The documentation site with examples uses MkDocs along with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/). You can check out the site [here](https://maplibre.org/maplibre-native/android/examples/).

### Building

To build the Examples Documentation you need to have Docker installed.

From `platform/android`, run:

```
make mkdocs
```

Next, visit [`http://localhost:8000/maplibre-native/android/examples/`](http://localhost:8000/maplibre-native/android/examples/).

### Snippets

We use [a Markdown extension for snippets](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/#snippet-sections). This way code can be referenced instead of copy pasted into the documentation. This avoids code examples from becoming out of date or failing to compile. The syntax is as follows:

````kotlin
// --8<-- [start:fun]
fun double(x: Int): Int {
return 2 * x
}
// --8<-- [end:fun]
````

Next, you'll be able to reference that piece of code in Markdown like so:

```
--8<-- "example.kt:fun"
```

Where `example.kt` is the path to the file.

### Static Assets

Static assets are ideally uploaded to the [MapLibre Native S3 Bucket](https://maplibre-native.s3.eu-central-1.amazonaws.com/index.html#android-documentation-resources/).

Please open an issue with the ARN of your AWS account to get upload privileges.

You can use the macro `{{ s3_url("filename.example") }}` which will use a CDN instead of linking to the S3 bucket directly.
91 changes: 91 additions & 0 deletions docs/mdbook/src/android/android-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# MapLibre Android Tests

## Render Tests

To run the render tests for Android, run the configuration for the `androidRenderTest.app` module.

### Filtering Render Tests

You can filter the tests to run by passing a flag to the file `platform/android/src/test/render_test_runner.cpp`:

```cpp
std::vector<std::string> arguments = {..., "-f", "background-color/literal"};
```
### Viewing the Results
Once the application quits, use the Device Explorer to navigate to `/data/data/org.maplibre.render_test_runner/files`.
<img width="980" alt="image" src="https://github.com/maplibre/maplibre-native/assets/649392/0dc42d4a-6221-46b6-8352-1eb24d466e91">
Double click `android-render-test-runner-style.html`. Right click on the opened tab and select _Open In > Browser_. You should see that a single render test passed.
<img width="801" alt="image" src="https://github.com/maplibre/maplibre-native/assets/649392/33e88999-7787-492f-afd9-f5a3e3fd61f7">
Alternatively to download (and open) the results from the command line, use:
```
adb shell "run-as org.maplibre.render_test_runner cat files/metrics/android-render-test-runner-style.html" > android-render-test-runner-style.html
open android-render-test-runner-style.html
```
### Updating the Render Tests
Now let's edit `metrics/integration/render-tests/background-color/literal/style.json`, change this line:
```
"background-color": "red"
```
to
```
"background-color": "yellow"
```
We need to make sure that the new `data.zip` with the data for the render tests is installed on the device. You can use the following commands:
```
tar chf render-test/android/app/src/main/assets/data.zip --format=zip --files-from=render-test/android/app/src/main/assets/to_zip.txt
adb push render-test/android/app/src/main/assets/data.zip /data/local/tmp/data.zip
adb shell chmod 777 /data/local/tmp/data.zip
adb shell "run-as org.maplibre.render_test_runner unzip -o /data/local/tmp/data.zip -d files"
```
Rerun the render test app and reload the Device Explorer. When you re-open the HTML file with the results you should now see a failing test:
<img width="685" alt="image" src="https://github.com/maplibre/maplibre-native/assets/649392/303ad75a-cf74-4b8c-927c-c9bd59a79de4">
Now download the `actual.png` in `metrics/integration/render-tests/background-color/literal` with the Device Explorer. Replace the corresponding `expected.png` on your local file system. Upload the new render test data again and run the test app once more.
<img width="800" alt="image" src="https://github.com/maplibre/maplibre-native/assets/649392/04734c6a-9cf1-489a-b9bb-8d857581261c">
Of we don't want to commit this change. But know you can add and debug (Android) render tests.
## Instrumentation Tests
To run the instrumentation tests, choose the "Instrumentation Tests" run configuration.
Your device needs remain unlocked for the duration of the tests.
## C++ Unit Tests
There is a separate Gradle project that contains a test app which runs the C++ Unit Tests. It does not depend on the Android platform implementations.
You can find the project in `test/android.` You can open this project in Android Studio and run the C++ Tests on an Android device or Simulator.
To run a particular set of tests you can modify the `--gtest_filter` flag in `platform/android/src/test/test_runner.cpp`. See the [GoogleTest documentation](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) for details how to use this flag.
### AWS Device Farm
The instrumentation tests and C++ unit tests are running on AWS Device Farm. To see the results and the logs, go to:
[https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs](https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs).
Use the following login details (this is a read-only account):
| | |
|------------|------------|
| Alias | `maplibre` |
| Username | `maplibre` |
| Password | `maplibre` |
5 changes: 4 additions & 1 deletion docs/mdbook/src/design/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> [!NOTE]
> These notes are partially outdated since the [renderer modularization](https://github.com/maplibre/maplibre-native/blob/main/design-proposals/2022-10-27-rendering-modularization.md).
# Design

This section is dedicated to documenting current state of MapLibre Native. [Architectural Problems and Recommendations](./archictural-problems-and-recommendations.md) section notes recommendations for future improvements from an architectural perspective.
This section is dedicated to documenting current state of MapLibre Native as of end 2022. [Architectural Problems and Recommendations](./archictural-problems-and-recommendations.md) section notes recommendations for future improvements from an architectural perspective.
2 changes: 2 additions & 0 deletions docs/mdbook/src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*[MapLibre Native](https://github.com/maplibre/maplibre-native)* is a community led fork of *Mapbox GL Native*. It's a C++ library that powers
vector maps in native applications on multiple platforms by taking stylesheets that conform to the *[MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/)*, a fork of the
Mapbox Style Spec. Since it is derived from Mapbox's original work it also uses *Mapbox Vector Tile Specification* as its choice of vector tile format.

This documentation is intended for developers of MapLibre Native. If you are interested in *using* MapLibre Native, check out the [main `README.md`](https://github.com/maplibre/maplibre-native?tab=readme-ov-file#maplibre-native) on GitHub.
92 changes: 12 additions & 80 deletions platform/ios/CONTRIBUTING.md → docs/mdbook/src/ios/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
# Contributing

## Downloading Source

Download the source and install all submodules if you have not already, by running the following from the root of the repository.

```
git clone --recurse-submodules [email protected]:maplibre/maplibre-native.git
cd maplibre-native
```
# MapLibre iOS Developer Guide

## Bazel

Expand Down Expand Up @@ -56,91 +47,32 @@ Try to run the example App in the simulator and on a device to confirm your setu
> [!IMPORTANT]
> The Bazel configuration files are the source of truth of the build configuration. All changes to the build settings need to be done through Bazel, not in Xcode.
### Troubleshooting Provisioning Profiles
### Troubleshooting

#### Provisioning Profiles

If you get a Python `KeyError` when processing provisioning profiles, you probably have some _really_ old or corrupted profiles.

Have a look through `~/Library/MobileDevice/Provisioning\ Profiles` and remove any expired profiles. Removing all profiles here can also resolve some issues.

## Using Bazel from the Command Line
#### Cleaning Bazel environments

It is also possible to build and run the test application in a simulator from the command line without opening Xcode.
You should almost never have to do this, but sometimes problems can be solved with:

```
bazel run //platform/ios:App --//:renderer=metal
bazel clean --expunge
```

You can also build targets from the command line. For example, if you want to build your own XCFramework, see the 'Build XCFramework' step in the [iOS CI workflow](../../.github/workflows/ios-ci.yml).

## Render Tests

To run the render tests, run the `RenderTest` target from iOS.
## Using Bazel from the Command Line

When running in a simulator, use
It is also possible to build and run the test application in a simulator from the command line without opening Xcode.

```
# check for 'DataContainer' of the app with `*.maplibre.RenderTestApp` id
xcrun simctl listapps booted
bazel run //platform/ios:App --//:renderer=metal
```

to get the data directory of the render test app. This allows you to inspect test results. When adding new tests, the generated expectations and `actual.png` file can be copied into the source directory from here.

## C++ Unit Tests

Run the tests from the `CppUnitTests` target in Xcode to run the C++ Unit Tests on iOS.
You can also build targets from the command line. For example, if you want to build your own XCFramework, see the 'Build XCFramework' step in the [iOS CI workflow](../../.github/workflows/ios-ci.yml).

## Swift App

There is also an example app built with Swift instead of Objective-C. The target is called `MapLibreApp` and the source code lives in `platform/ios/app-swift`.

## Documentation

We use [DocC](https://www.swift.org/documentation/docc) for documentation. You need to have [aws-cli](https://github.com/aws/aws-cli) installed to download the resources from S3 (see below). Run the following command:

```
aws s3 sync --no-sign-request "s3://maplibre-native/ios-documentation-resources" "platform/ios/MapLibre.docc/Resources"
```

Then, to build the documentation locally, run the following command:

```
platform/ios/scripts/docc.sh preview
```

### Resources

Resources like images should not be checked in but should be uploaded to the [S3 Bucket](https://s3.eu-central-1.amazonaws.com/maplibre-native/index.html#ios-documentation-resources/). You can share a `.zip` with all files that should be added in the PR.

If you want to get direct access you need an AWS account to get permissions to upload files. Create an account and authenticate with aws-cli. Share the account ARN that you can get with

```
aws sts get-caller-identity
```

### Examples

The code samples in the documentation should ideally be compiled on CI so they do not go out of date.

Fence your example code with

```swift
// #-example-code(LineTapMap)
...
// #-end-example-code
```

Prefix your documentation code block with

````md
<!-- include-example(LineTapMap) -->

```swift
...
```
````

Then the code block will be updated when you run:

```sh
node scripts/update-ios-examples.mjs
```
There is also an example app built with Swift instead of Objective-C. The target is called `MapLibreApp` and the source code lives in `platform/ios/app-swift`.
Loading

0 comments on commit c7e6b0c

Please sign in to comment.