Skip to content

Commit

Permalink
refactor: add generated API docs to git (#802)
Browse files Browse the repository at this point in the history
* refactor: add generated API docs to git

* refactor: add comment to autogenerated files
  • Loading branch information
JuroOravec authored Dec 2, 2024
1 parent 9879a0a commit a3710fe
Show file tree
Hide file tree
Showing 12 changed files with 1,163 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/docs/.gitignore

This file was deleted.

105 changes: 105 additions & 0 deletions src/docs/reference/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!-- Autogenerated by reference.py -->

# API


::: django_components.Component
options:
show_if_no_docstring: true

::: django_components.ComponentFileEntry
options:
show_if_no_docstring: true

::: django_components.ComponentRegistry
options:
show_if_no_docstring: true

::: django_components.ComponentVars
options:
show_if_no_docstring: true

::: django_components.ComponentView
options:
show_if_no_docstring: true

::: django_components.ComponentsSettings
options:
show_if_no_docstring: true

::: django_components.ContextBehavior
options:
show_if_no_docstring: true

::: django_components.EmptyDict
options:
show_if_no_docstring: true

::: django_components.EmptyTuple
options:
show_if_no_docstring: true

::: django_components.RegistrySettings
options:
show_if_no_docstring: true

::: django_components.Slot
options:
show_if_no_docstring: true

::: django_components.SlotContent
options:
show_if_no_docstring: true

::: django_components.SlotFunc
options:
show_if_no_docstring: true

::: django_components.SlotRef
options:
show_if_no_docstring: true

::: django_components.SlotResult
options:
show_if_no_docstring: true

::: django_components.TagFormatterABC
options:
show_if_no_docstring: true

::: django_components.TagResult
options:
show_if_no_docstring: true

::: django_components.autodiscover
options:
show_if_no_docstring: true

::: django_components.cached_template
options:
show_if_no_docstring: true

::: django_components.get_component_dirs
options:
show_if_no_docstring: true

::: django_components.get_component_files
options:
show_if_no_docstring: true

::: django_components.import_libraries
options:
show_if_no_docstring: true

::: django_components.register
options:
show_if_no_docstring: true

::: django_components.registry
options:
show_if_no_docstring: true

::: django_components.render_dependencies
options:
show_if_no_docstring: true

166 changes: 166 additions & 0 deletions src/docs/reference/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<!-- Autogenerated by reference.py -->

# Commands

These are all the [Django management commands](https://docs.djangoproject.com/en/5.1/ref/django-admin)
that will be added by installing `django_components`:


## `upgradecomponent`

```txt
usage: manage.py upgradecomponent [-h] [--path PATH] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
[--force-color] [--skip-checks]
```



<a href="https://github.com/EmilStenstrom/django-components/tree/master/.venv/lib/python3.11/site-packages/django_components/management/commands/upgradecomponent.py#L12" target="_blank">See source code</a>



Updates component and component_block tags to the new syntax

**Options:**

- `-h`, `--help`
- show this help message and exit
- `--path PATH`
- Path to search for components
- `--version`
- Show program's version number and exit.
- `-v {0,1,2,3}`, `--verbosity {0,1,2,3}`
- Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
- `--settings SETTINGS`
- The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used.
- `--pythonpath PYTHONPATH`
- A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
- `--traceback`
- Raise on CommandError exceptions.
- `--no-color`
- Don't colorize the command output.
- `--force-color`
- Force colorization of the command output.
- `--skip-checks`
- Skip system checks.





## `startcomponent`

```txt
usage: manage.py startcomponent [-h] [--path PATH] [--js JS] [--css CSS] [--template TEMPLATE] [--force] [--verbose] [--dry-run] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks]
name
```



<a href="https://github.com/EmilStenstrom/django-components/tree/master/.venv/lib/python3.11/site-packages/django_components/management/commands/startcomponent.py#L8" target="_blank">See source code</a>



Create a new django component.

**Positional Arguments:**

- `name`
- The name of the component to create. This is a required argument.

**Options:**

- `-h`, `--help`
- show this help message and exit
- `--path PATH`
- The path to the component's directory. This is an optional argument. If not provided, the command will use the `COMPONENTS.dirs` setting from your Django settings.
- `--js JS`
- The name of the JavaScript file. This is an optional argument. The default value is `script.js`.
- `--css CSS`
- The name of the CSS file. This is an optional argument. The default value is `style.css`.
- `--template TEMPLATE`
- The name of the template file. This is an optional argument. The default value is `template.html`.
- `--force`
- This option allows you to overwrite existing files if they exist. This is an optional argument.
- `--verbose`
- This option allows the command to print additional information during component creation. This is an optional argument.
- `--dry-run`
- This option allows you to simulate component creation without actually creating any files. This is an optional argument. The default value is `False`.
- `--version`
- Show program's version number and exit.
- `-v {0,1,2,3}`, `--verbosity {0,1,2,3}`
- Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
- `--settings SETTINGS`
- The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used.
- `--pythonpath PYTHONPATH`
- A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
- `--traceback`
- Raise on CommandError exceptions.
- `--no-color`
- Don't colorize the command output.
- `--force-color`
- Force colorization of the command output.
- `--skip-checks`
- Skip system checks.




### Management Command Usage

To use the command, run the following command in your terminal:

```bash
python manage.py startcomponent <name> --path <path> --js <js_filename> --css <css_filename> --template <template_filename> --force --verbose --dry-run
```

Replace `<name>`, `<path>`, `<js_filename>`, `<css_filename>`, and `<template_filename>` with your desired values.

### Management Command Examples

Here are some examples of how you can use the command:

#### Creating a Component with Default Settings

To create a component with the default settings, you only need to provide the name of the component:

```bash
python manage.py startcomponent my_component
```

This will create a new component named `my_component` in the `components` directory of your Django project. The JavaScript, CSS, and template files will be named `script.js`, `style.css`, and `template.html`, respectively.

#### Creating a Component with Custom Settings

You can also create a component with custom settings by providing additional arguments:

```bash
python manage.py startcomponent new_component --path my_components --js my_script.js --css my_style.css --template my_template.html
```

This will create a new component named `new_component` in the `my_components` directory. The JavaScript, CSS, and template files will be named `my_script.js`, `my_style.css`, and `my_template.html`, respectively.

#### Overwriting an Existing Component

If you want to overwrite an existing component, you can use the `--force` option:

```bash
python manage.py startcomponent my_component --force
```

This will overwrite the existing `my_component` if it exists.

#### Simulating Component Creation

If you want to simulate the creation of a component without actually creating any files, you can use the `--dry-run` option:

```bash
python manage.py startcomponent my_component --dry-run
```

This will simulate the creation of `my_component` without creating any files.


15 changes: 15 additions & 0 deletions src/docs/reference/components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Autogenerated by reference.py -->

# Components

These are the components provided by django_components.


::: django_components.components.dynamic.DynamicComponent
options:
inherited_members: false
show_root_heading: true
show_signature: false
separate_signature: false
members: false

17 changes: 17 additions & 0 deletions src/docs/reference/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Autogenerated by reference.py -->

# Exceptions


::: django_components.AlreadyRegistered
options:
show_if_no_docstring: true

::: django_components.NotRegistered
options:
show_if_no_docstring: true

::: django_components.TagProtectedError
options:
show_if_no_docstring: true

16 changes: 16 additions & 0 deletions src/docs/reference/middlewares.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Autogenerated by reference.py -->

# Middlewares


::: django_components.dependencies.ComponentDependencyMiddleware
options:
inherited_members: false
show_root_heading: true
show_signature: false
separate_signature: false
show_symbol_type_heading: false
show_symbol_type_toc: false
show_if_no_docstring: true
show_labels: false

Loading

0 comments on commit a3710fe

Please sign in to comment.