# Packages and Documentation Comments

This page: https://emojicode-ide.com/en/docs/advanced/packages/

## Importing a package (📦)

`📦 name 🏠` imports a package. The standard library `s` is imported from the start, even if you don't write it. In this IDE, besides `s`, you can use `files`, `json`, and `testtube`.

```emojicode
📦 json 🏠

🏁 🍇
  🍺 ⚪️🕊🌸 🔤{"name": "Emoji", "age": 3}🔤❗️ ➡️ value
  ↪️ 🔲 value 🍯🐚⚪️🍆 ➡️ object 🍇
    ↪️ 🐽 object 🔤name🔤❗️ ➡️ name 🍇
      ↪️ 🔲 name 🔡 ➡️ text 🍇
        😀 text❗️
      🍉
    🍉
  🍉
🍉
```

Output:

```text
Emoji
```

`🏠` means “put the imported types into the same namespace as my own file.” If you write a namespace emoji instead of `🏠`, the types go into that namespace. You then use a type in that namespace by writing `🔶NamespaceType`.

## Reading and writing files (📦 files)

In this IDE, files exist in memory only while the program is running.

```emojicode
📦 files 🏠

🏁 🍇
  🍺 📻🐇📄 🔤memo.txt🔤 📇 🔤Hello🔤❗️❗️
  🍺 📇🐇📄 🔤memo.txt🔤❗️ ➡️ data
  😀 🍺 🔡 data❗️❗️
🍉
```

Output:

```text
Hello
```

## Writing tests (📦 testtube)

`testtube` is a package for writing tests.

```emojicode
📦 testtube 🏠

🐇 🔬 🧪 🍇
  ✒️ ❗️ 🏁 🍇
    ⛔👇 1 ➕ 1 🙌 2 🔤addition🔤❗️
    🔢👇 📐 🔤abc🔤❗️ 3 🔤length🔤❗️
  🍉
🍉

🏁 ➡️ 🔢 🍇
  ↩️ 👔🆕🔬❗️❗️
🍉
```

Output:

```text
2 assertions, 0 failures
```

## Documentation comments (📗, 📘)

Apart from ordinary comments (`💭`), there are comments for describing types and packages (for `💭`, see [Hello World](https://emojicode-ide.com/en/docs/intro/hello.md)).

| Syntax | Meaning |
|---|---|
| `📗 … 📗` | Describes a type or method. It becomes the description of the type or method right after it |
| `📘 … 📘` | Describes the whole package |

```emojicode
📗 A type that greets people 📗
🐇 👋 🍇
  🆕 🍇🍉
  📗 Takes a name and returns a greeting 📗
  ❗️ 💬 name 🔡 ➡️ 🔡 🍇
    ↩️ 🔤Hello, 🧲name🧲🔤
  🍉
🍉

🏁 🍇
  😀 💬 🆕👋❗️ 🔤Emoji🔤❗️❗️
🍉
```

Output:

```text
Hello, Emoji
```

## Things you cannot use in this IDE

- `📜 🔤filename🔤` … includes another file. This IDE compiles only one file, so you cannot use it.
- `🌍` … exports a type outside the package. You use it when you make a package.
- `📻`, `🔗` … connect to functions written in C++ or other languages. You cannot use them in this IDE.
