We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[RFC] Support multidoc yaml files
**Is your feature request related to a problem? Please describe.**
Sometimes it can be difficult or impossible to pass multiple files with config fragments. yaml support multiple documents in one file and `safe_load_all` from pyaml api loads that accordingly. It is standard yaml feature, it would be nice to support it and make in usable in cases when passing one file (composited from more files) would be easier.

**Describe the solution you'd like**
Support `safe_load_all` as yaml loader.

**Describe alternatives you've considered**
Passing multiple files will do the work, however it doesn't have to be always straightforward.

**Additional context**
I have prepared a patch


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dynaconf/loaders/yaml_loader.py`
Content:
```
1 from __future__ import annotations
2 
3 import sys
4 from pathlib import Path
5 from typing import TextIO
6 from warnings import warn
7 
8 from dynaconf import default_settings
9 from dynaconf.constants import YAML_EXTENSIONS
10 from dynaconf.loaders.base import BaseLoader
11 from dynaconf.utils import object_merge
12 from dynaconf.utils.parse_conf import try_to_encode
13 from dynaconf.vendor.ruamel import yaml
14 
15 # Add support for Dynaconf Lazy values to YAML dumper
16 yaml.SafeDumper.yaml_representers[
17     None
18 ] = lambda self, data: yaml.representer.SafeRepresenter.represent_str(
19     self, try_to_encode(data)
20 )
21 
22 
23 def load(obj, env=None, silent=True, key=None, filename=None, validate=False):
24     """
25     Reads and loads in to "obj" a single key or all keys from source file.
26 
27     :param obj: the settings instance
28     :param env: settings current env default='development'
29     :param silent: if errors should raise
30     :param key: if defined load a single key, else load all in env
31     :param filename: Optional custom filename to load
32     :return: None
33     """
34     # Resolve the loaders
35     # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
36     # Possible values are `safe_load, full_load, unsafe_load, load`
37     yaml_reader = getattr(
38         yaml, obj.get("YAML_LOADER_FOR_DYNACONF"), yaml.safe_load
39     )
40     if yaml_reader.__name__ == "unsafe_load":  # pragma: no cover
41         warn(
42             "yaml.unsafe_load is deprecated."
43             " Please read https://msg.pyyaml.org/load for full details."
44             " Try to use full_load or safe_load."
45         )
46 
47     loader = BaseLoader(
48         obj=obj,
49         env=env,
50         identifier="yaml",
51         extensions=YAML_EXTENSIONS,
52         file_reader=yaml_reader,
53         string_reader=yaml_reader,
54         validate=validate,
55     )
56     loader.load(
57         filename=filename,
58         key=key,
59         silent=silent,
60     )
61 
62 
63 def write(settings_path, settings_data, merge=True):
64     """Write data to a settings file.
65 
66     :param settings_path: the filepath
67     :param settings_data: a dictionary with data
68     :param merge: boolean if existing file should be merged with new data
69     :param stdout: boolean if should output to stdout instead of file
70     """
71     settings_path = Path(settings_path)
72     if settings_path.exists() and merge:  # pragma: no cover
73         with open(
74             str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF
75         ) as open_file:
76             object_merge(yaml.safe_load(open_file), settings_data)
77 
78     with open(
79         str(settings_path),
80         "w",
81         encoding=default_settings.ENCODING_FOR_DYNACONF,
82     ) as open_file:
83         yaml.dump(
84             settings_data,
85             open_file,
86             Dumper=yaml.dumper.SafeDumper,
87             explicit_start=True,
88             indent=2,
89             default_flow_style=False,
90         )
91
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dynaconf/loaders/yaml_loader.py b/dynaconf/loaders/yaml_loader.py
--- a/dynaconf/loaders/yaml_loader.py
+++ b/dynaconf/loaders/yaml_loader.py
@@ -20,6 +20,41 @@
 )
 
 
+class AllLoader(BaseLoader):
+    """YAML Loader to load multi doc files"""
+
+    @staticmethod
+    def _assign_data(data, source_file, content):
+        """Helper to iterate through all docs in a file"""
+        content = tuple(content)
+        if len(content) == 1:
+            data[source_file] = content[0]
+        elif len(content) > 1:
+            for i, doc in enumerate(content):
+                data[f"{source_file}[{i}]"] = doc
+
+    def get_source_data(self, files):
+        data = {}
+        for source_file in files:
+            if source_file.endswith(self.extensions):
+                try:
+                    with open(source_file, **self.opener_params) as open_file:
+                        content = self.file_reader(open_file)
+                        self.obj._loaded_files.append(source_file)
+                        self._assign_data(data, source_file, content)
+                except OSError as e:
+                    if ".local." not in source_file:
+                        warn(
+                            f"{self.identifier}_loader: {source_file} "
+                            f":{str(e)}"
+                        )
+            else:
+                # for tests it is possible to pass string
+                content = self.string_reader(source_file)
+                self._assign_data(data, source_file, content)
+        return data
+
+
 def load(obj, env=None, silent=True, key=None, filename=None, validate=False):
     """
     Reads and loads in to "obj" a single key or all keys from source file.
@@ -33,7 +68,8 @@
     """
     # Resolve the loaders
     # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
-    # Possible values are `safe_load, full_load, unsafe_load, load`
+    # Possible values are:
+    #   `safe_load, full_load, unsafe_load, load, safe_load_all`
     yaml_reader = getattr(
         yaml, obj.get("YAML_LOADER_FOR_DYNACONF"), yaml.safe_load
     )
@@ -44,7 +80,11 @@
             " Try to use full_load or safe_load."
         )
 
-    loader = BaseLoader(
+    _loader = BaseLoader
+    if yaml_reader.__name__.endswith("_all"):
+        _loader = AllLoader
+
+    loader = _loader(
         obj=obj,
         env=env,
         identifier="yaml",

{"golden_diff": "diff --git a/dynaconf/loaders/yaml_loader.py b/dynaconf/loaders/yaml_loader.py\n--- a/dynaconf/loaders/yaml_loader.py\n+++ b/dynaconf/loaders/yaml_loader.py\n@@ -20,6 +20,41 @@\n )\n \n \n+class AllLoader(BaseLoader):\n+    \"\"\"YAML Loader to load multi doc files\"\"\"\n+\n+    @staticmethod\n+    def _assign_data(data, source_file, content):\n+        \"\"\"Helper to iterate through all docs in a file\"\"\"\n+        content = tuple(content)\n+        if len(content) == 1:\n+            data[source_file] = content[0]\n+        elif len(content) > 1:\n+            for i, doc in enumerate(content):\n+                data[f\"{source_file}[{i}]\"] = doc\n+\n+    def get_source_data(self, files):\n+        data = {}\n+        for source_file in files:\n+            if source_file.endswith(self.extensions):\n+                try:\n+                    with open(source_file, **self.opener_params) as open_file:\n+                        content = self.file_reader(open_file)\n+                        self.obj._loaded_files.append(source_file)\n+                        self._assign_data(data, source_file, content)\n+                except OSError as e:\n+                    if \".local.\" not in source_file:\n+                        warn(\n+                            f\"{self.identifier}_loader: {source_file} \"\n+                            f\":{str(e)}\"\n+                        )\n+            else:\n+                # for tests it is possible to pass string\n+                content = self.string_reader(source_file)\n+                self._assign_data(data, source_file, content)\n+        return data\n+\n+\n def load(obj, env=None, silent=True, key=None, filename=None, validate=False):\n     \"\"\"\n     Reads and loads in to \"obj\" a single key or all keys from source file.\n@@ -33,7 +68,8 @@\n     \"\"\"\n     # Resolve the loaders\n     # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation\n-    # Possible values are `safe_load, full_load, unsafe_load, load`\n+    # Possible values are:\n+    #   `safe_load, full_load, unsafe_load, load, safe_load_all`\n     yaml_reader = getattr(\n         yaml, obj.get(\"YAML_LOADER_FOR_DYNACONF\"), yaml.safe_load\n     )\n@@ -44,7 +80,11 @@\n             \" Try to use full_load or safe_load.\"\n         )\n \n-    loader = BaseLoader(\n+    _loader = BaseLoader\n+    if yaml_reader.__name__.endswith(\"_all\"):\n+        _loader = AllLoader\n+\n+    loader = _loader(\n         obj=obj,\n         env=env,\n         identifier=\"yaml\",\n", "issue": "[RFC] Support multidoc yaml files\n**Is your feature request related to a problem? Please describe.**\r\nSometimes it can be difficult or impossible to pass multiple files with config fragments. yaml support multiple documents in one file and `safe_load_all` from pyaml api loads that accordingly. It is standard yaml feature, it would be nice to support it and make in usable in cases when passing one file (composited from more files) would be easier.\r\n\r\n**Describe the solution you'd like**\r\nSupport `safe_load_all` as yaml loader.\r\n\r\n**Describe alternatives you've considered**\r\nPassing multiple files will do the work, however it doesn't have to be always straightforward.\r\n\r\n**Additional context**\r\nI have prepared a patch\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport sys\nfrom pathlib import Path\nfrom typing import TextIO\nfrom warnings import warn\n\nfrom dynaconf import default_settings\nfrom dynaconf.constants import YAML_EXTENSIONS\nfrom dynaconf.loaders.base import BaseLoader\nfrom dynaconf.utils import object_merge\nfrom dynaconf.utils.parse_conf import try_to_encode\nfrom dynaconf.vendor.ruamel import yaml\n\n# Add support for Dynaconf Lazy values to YAML dumper\nyaml.SafeDumper.yaml_representers[\n    None\n] = lambda self, data: yaml.representer.SafeRepresenter.represent_str(\n    self, try_to_encode(data)\n)\n\n\ndef load(obj, env=None, silent=True, key=None, filename=None, validate=False):\n    \"\"\"\n    Reads and loads in to \"obj\" a single key or all keys from source file.\n\n    :param obj: the settings instance\n    :param env: settings current env default='development'\n    :param silent: if errors should raise\n    :param key: if defined load a single key, else load all in env\n    :param filename: Optional custom filename to load\n    :return: None\n    \"\"\"\n    # Resolve the loaders\n    # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation\n    # Possible values are `safe_load, full_load, unsafe_load, load`\n    yaml_reader = getattr(\n        yaml, obj.get(\"YAML_LOADER_FOR_DYNACONF\"), yaml.safe_load\n    )\n    if yaml_reader.__name__ == \"unsafe_load\":  # pragma: no cover\n        warn(\n            \"yaml.unsafe_load is deprecated.\"\n            \" Please read https://msg.pyyaml.org/load for full details.\"\n            \" Try to use full_load or safe_load.\"\n        )\n\n    loader = BaseLoader(\n        obj=obj,\n        env=env,\n        identifier=\"yaml\",\n        extensions=YAML_EXTENSIONS,\n        file_reader=yaml_reader,\n        string_reader=yaml_reader,\n        validate=validate,\n    )\n    loader.load(\n        filename=filename,\n        key=key,\n        silent=silent,\n    )\n\n\ndef write(settings_path, settings_data, merge=True):\n    \"\"\"Write data to a settings file.\n\n    :param settings_path: the filepath\n    :param settings_data: a dictionary with data\n    :param merge: boolean if existing file should be merged with new data\n    :param stdout: boolean if should output to stdout instead of file\n    \"\"\"\n    settings_path = Path(settings_path)\n    if settings_path.exists() and merge:  # pragma: no cover\n        with open(\n            str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF\n        ) as open_file:\n            object_merge(yaml.safe_load(open_file), settings_data)\n\n    with open(\n        str(settings_path),\n        \"w\",\n        encoding=default_settings.ENCODING_FOR_DYNACONF,\n    ) as open_file:\n        yaml.dump(\n            settings_data,\n            open_file,\n            Dumper=yaml.dumper.SafeDumper,\n            explicit_start=True,\n            indent=2,\n            default_flow_style=False,\n        )\n", "path": "dynaconf/loaders/yaml_loader.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport sys\nfrom pathlib import Path\nfrom typing import TextIO\nfrom warnings import warn\n\nfrom dynaconf import default_settings\nfrom dynaconf.constants import YAML_EXTENSIONS\nfrom dynaconf.loaders.base import BaseLoader\nfrom dynaconf.utils import object_merge\nfrom dynaconf.utils.parse_conf import try_to_encode\nfrom dynaconf.vendor.ruamel import yaml\n\n# Add support for Dynaconf Lazy values to YAML dumper\nyaml.SafeDumper.yaml_representers[\n    None\n] = lambda self, data: yaml.representer.SafeRepresenter.represent_str(\n    self, try_to_encode(data)\n)\n\n\nclass AllLoader(BaseLoader):\n    \"\"\"YAML Loader to load multi doc files\"\"\"\n\n    @staticmethod\n    def _assign_data(data, source_file, content):\n        \"\"\"Helper to iterate through all docs in a file\"\"\"\n        content = tuple(content)\n        if len(content) == 1:\n            data[source_file] = content[0]\n        elif len(content) > 1:\n            for i, doc in enumerate(content):\n                data[f\"{source_file}[{i}]\"] = doc\n\n    def get_source_data(self, files):\n        data = {}\n        for source_file in files:\n            if source_file.endswith(self.extensions):\n                try:\n                    with open(source_file, **self.opener_params) as open_file:\n                        content = self.file_reader(open_file)\n                        self.obj._loaded_files.append(source_file)\n                        self._assign_data(data, source_file, content)\n                except OSError as e:\n                    if \".local.\" not in source_file:\n                        warn(\n                            f\"{self.identifier}_loader: {source_file} \"\n                            f\":{str(e)}\"\n                        )\n            else:\n                # for tests it is possible to pass string\n                content = self.string_reader(source_file)\n                self._assign_data(data, source_file, content)\n        return data\n\n\ndef load(obj, env=None, silent=True, key=None, filename=None, validate=False):\n    \"\"\"\n    Reads and loads in to \"obj\" a single key or all keys from source file.\n\n    :param obj: the settings instance\n    :param env: settings current env default='development'\n    :param silent: if errors should raise\n    :param key: if defined load a single key, else load all in env\n    :param filename: Optional custom filename to load\n    :return: None\n    \"\"\"\n    # Resolve the loaders\n    # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation\n    # Possible values are:\n    #   `safe_load, full_load, unsafe_load, load, safe_load_all`\n    yaml_reader = getattr(\n        yaml, obj.get(\"YAML_LOADER_FOR_DYNACONF\"), yaml.safe_load\n    )\n    if yaml_reader.__name__ == \"unsafe_load\":  # pragma: no cover\n        warn(\n            \"yaml.unsafe_load is deprecated.\"\n            \" Please read https://msg.pyyaml.org/load for full details.\"\n            \" Try to use full_load or safe_load.\"\n        )\n\n    _loader = BaseLoader\n    if yaml_reader.__name__.endswith(\"_all\"):\n        _loader = AllLoader\n\n    loader = _loader(\n        obj=obj,\n        env=env,\n        identifier=\"yaml\",\n        extensions=YAML_EXTENSIONS,\n        file_reader=yaml_reader,\n        string_reader=yaml_reader,\n        validate=validate,\n    )\n    loader.load(\n        filename=filename,\n        key=key,\n        silent=silent,\n    )\n\n\ndef write(settings_path, settings_data, merge=True):\n    \"\"\"Write data to a settings file.\n\n    :param settings_path: the filepath\n    :param settings_data: a dictionary with data\n    :param merge: boolean if existing file should be merged with new data\n    :param stdout: boolean if should output to stdout instead of file\n    \"\"\"\n    settings_path = Path(settings_path)\n    if settings_path.exists() and merge:  # pragma: no cover\n        with open(\n            str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF\n        ) as open_file:\n            object_merge(yaml.safe_load(open_file), settings_data)\n\n    with open(\n        str(settings_path),\n        \"w\",\n        encoding=default_settings.ENCODING_FOR_DYNACONF,\n    ) as open_file:\n        yaml.dump(\n            settings_data,\n            open_file,\n            Dumper=yaml.dumper.SafeDumper,\n            explicit_start=True,\n            indent=2,\n            default_flow_style=False,\n        )\n", "path": "dynaconf/loaders/yaml_loader.py"}]}