Skip to content

Commit e0fef0f

Browse files
Improve docs
1 parent 55da258 commit e0fef0f

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

docs/architecture/frameworks.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,47 @@
22

33
MicroPythonOS provides a unified framework architecture for accessing system services. All frameworks follow a consistent, simple pattern that makes them easy to discover, use, and extend.
44

5+
## Importing from mpos
6+
7+
**Apps should only import from the `mpos` module directly.** Importing from submodules (such as `mpos.ui`, `mpos.content`, etc.) is not necessary and should be avoided.
8+
9+
All frameworks and utilities you need are available through the main `mpos` module. If you find yourself needing to import from a submodule, or if you would like a new framework to be created, please [create a GitHub issue](https://github.com/MicroPythonOS/MicroPythonOS/issues) describing your use case.
10+
11+
### Correct Import Style
12+
13+
Import directly from `mpos`:
14+
15+
```python
16+
from mpos import DisplayMetrics
17+
18+
DisplayMetrics.width()
19+
```
20+
21+
Or import the module and use it:
22+
23+
```python
24+
import mpos
25+
26+
mpos.DisplayMetrics.width()
27+
```
28+
29+
### Avoid Submodule Imports
30+
31+
Do not import from submodules:
32+
33+
```python
34+
# ❌ Don't do this
35+
from mpos.ui import DisplayMetrics
36+
from mpos.content import AppManager
37+
```
38+
39+
Instead, use the main `mpos` module which re-exports everything you need:
40+
41+
```python
42+
# ✅ Do this instead
43+
from mpos import DisplayMetrics, AppManager
44+
```
45+
546
## Overview
647

748
Frameworks are centralized services that provide access to system capabilities like audio, networking, camera, sensors, and task management. They follow a **singleton class pattern with class methods**, ensuring a predictable and discoverable API across the entire system.
@@ -60,7 +101,7 @@ class MyFramework:
60101
Manages app discovery, installation, launching, and version management.
61102

62103
```python
63-
from mpos.content.app_manager import AppManager
104+
from mpos import AppManager
64105

65106
# Get all installed apps
66107
apps = AppManager.get_app_list()
@@ -191,16 +232,7 @@ Frameworks should be initialized once at system startup in the board initializat
191232

192233
```python
193234
# In board/your_board.py
194-
from mpos import (
195-
AppearanceManager,
196-
AudioFlinger,
197-
DownloadManager,
198-
ConnectivityManager,
199-
CameraManager,
200-
SensorManager,
201-
TaskManager
202-
)
203-
from mpos.content.app_manager import AppManager
235+
from mpos import AppearanceManager, AudioFlinger, DownloadManager, ConnectivityManager, CameraManager, SensorManager, TaskManager, AppManager
204236

205237
def init_frameworks():
206238
"""Initialize all frameworks."""
@@ -292,22 +324,9 @@ class MyFramework:
292324
All frameworks are imported consistently as classes:
293325

294326
```python
295-
from mpos import (
296-
AppearanceManager,
297-
AudioFlinger,
298-
CameraManager,
299-
ConnectivityManager,
300-
DownloadManager,
301-
SensorManager,
302-
SharedPreferences,
303-
TaskManager,
304-
WifiService,
305-
)
306-
from mpos.content.app_manager import AppManager
327+
from mpos import AppearanceManager, AudioFlinger, CameraManager, ConnectivityManager, DownloadManager, SensorManager, SharedPreferences, TaskManager, WifiService, AppManager
307328
```
308329

309-
**Note:** AppManager is imported from `mpos.content.app_manager` rather than the main `mpos` module.
310-
311330
## Benefits of Harmonization
312331

313332
| Aspect | Before | After |

0 commit comments

Comments
 (0)