diff --git a/README.md b/README.md index 3bfde01..d494050 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ Finally include the `rest_framework_docs` urls in your `urls.py`: You can find detailed information about the package's settings at [the docs](http://drfdocs.com/settings/). REST_FRAMEWORK_DOCS = { - 'HIDE_DOCS': True # Default: False + 'HIDE_DOCS': True, # Default: False + 'DESC_TABLE': True # Default: False } diff --git a/docs/settings.md b/docs/settings.md index abd2106..331ab5f 100755 --- a/docs/settings.md +++ b/docs/settings.md @@ -19,11 +19,17 @@ You can use hidden to prevent your docs from showing up in different environment 'HIDE_DOCS': os.environ.get('HIDE_DRFDOCS', False) } +##### DESC_TABLE +You can use Table representation to make your fields list in the documentation clear. So We can change representation by adding single line inside the `REST_FRAMEWORK_DOCS` in `settings.py`. + + 'DESC_TABLE': os.environ.get('DESCRIBE_TABLE', False) + + Then set the value of the environment variable `HIDE_DRFDOCS` for each environment (ie. Use `.env` files) ### List of Settings -| Setting | Type | Options | Default | -|---------|---------|-----------------|---------| -|HIDE_DOCS| Boolean | `True`, `False` | `False` | -| | | | | +| Setting | Type | Options | Default | +|----------|---------|-----------------|---------| +|HIDE_DOCS | Boolean | `True`, `False` | `False` | +|DESC_TABLE| Boolean | `True`, `False` | `False` | diff --git a/rest_framework_docs/api_endpoint.py b/rest_framework_docs/api_endpoint.py index 953f9a0..8f7b7f5 100644 --- a/rest_framework_docs/api_endpoint.py +++ b/rest_framework_docs/api_endpoint.py @@ -122,7 +122,8 @@ def __get_serializer_fields__(self, serializer): "type": str(field.__class__.__name__), "sub_fields": sub_fields, "required": field.required, - "to_many_relation": to_many_relation + "to_many_relation": to_many_relation, + "max_length": (field.__dict__.get('max_length', '-') if field.__dict__.get('max_length', '-') is not None else '-') }) # FIXME: # Show more attibutes of `field`? diff --git a/rest_framework_docs/settings.py b/rest_framework_docs/settings.py index 2853a7b..50b230b 100644 --- a/rest_framework_docs/settings.py +++ b/rest_framework_docs/settings.py @@ -5,7 +5,8 @@ class DRFSettings(object): def __init__(self): self.drf_settings = { - "HIDE_DOCS": self.get_setting("HIDE_DOCS") or False + "HIDE_DOCS": self.get_setting("HIDE_DOCS") or False, + "DESC_TABLE": self.get_setting("DESC_TABLE") or False } def get_setting(self, name): diff --git a/rest_framework_docs/templates/rest_framework_docs/home.html b/rest_framework_docs/templates/rest_framework_docs/home.html index e13e5a5..11f2b1c 100644 --- a/rest_framework_docs/templates/rest_framework_docs/home.html +++ b/rest_framework_docs/templates/rest_framework_docs/home.html @@ -1,3 +1,24 @@ + + +
+ + {% extends "rest_framework_docs/docs.html" %} {% load drfdocs_filters %} @@ -65,8 +86,29 @@Fields details:
+Field Name | +Field Type | +Max Length | +Is Required | +
---|---|---|---|
{{ field.name }} | +{{ field.type }} | +{{ field.max_length }} | +{{ field.required }} | +
Fields:
{%include "rest_framework_docs/components/fields_list.html" with fields=endpoint.fields %} + {% endif %} {% elif not endpoint.errors %}No fields.
{% endif %} @@ -99,3 +141,4 @@