Repository: kedro-org/kedro
File: kedro/io/data_catalog.py (Python)

Code before:
        Example:
        ::

            >>> from kedro_datasets.pandas import CSVDataset, ParquetDataset
            >>>
            >>> io = DataCatalog(datasets={
            >>>                   "cars": CSVDataset(filepath="cars.csv")
            >>>                  })
            >>> additional = {
            >>>     "planes": ParquetDataset("planes.parq"),
            >>>     "boats": CSVDataset(filepath="boats.csv")
            >>> }
            >>>
            >>> io.add_all(additional)
            >>>
            >>> assert io.list() == ["cars", "planes", "boats"]
        """
        for name, dataset in datasets.items():
            self.add(name, dataset, replace)

    def add_feed_dict(self, feed_dict: dict[str, Any], replace: bool = False) -> None:
        """This function adds datasets to the ``DataCatalog`` using the data provided through the `feed_dict`.

        `feed_dict` dictionary key is used as a dataset name, and a value is used to create an instance of
        ``MemoryDataset`` before adding to the ``DataCatalog`` for all the value types except of ``AbstractDataset``.
        In the last case, the ``AbstractDataset`` is added as it is.

        Has `from_dict` alias, so it can be called using `from_dict` name instead.
        Will be fully renamed to `from_dict` in the `0.20.0` version.

        Args:
            feed_dict: A feed dict with data to be added to the ``DataCatalog``.
            replace: Specifies whether to replace an existing dataset with the same name in the ``DataCatalog``.

        Example:
        ::

            >>> from kedro_datasets.pandas import CSVDataset
            >>> import pandas as pd
            >>>
            >>> df = pd.DataFrame({"col1": [1, 2],
            >>>                    "col2": [4, 5],
            >>>                    "col3": [5, 6]})
            >>>
            >>> catalog = DataCatalog()
            >>> catalog.add_feed_dict({
            >>>     "data_df": df
            >>> }, replace=True)
            >>>
            >>> assert catalog.load("data_df").equals(df)
            >>>

Review comment (refactor):
What about

```suggestion
        `feed_dict` keys are used as dataset names, and values can either be raw data or instances of ``AbstractDataset``.
        In the former case, instances of ``MemoryDataset`` are automatically created before adding to the ``DataCatalog``.
```

?

Code after:
        Example:
        ::

            >>> from kedro_datasets.pandas import CSVDataset, ParquetDataset
            >>>
            >>> io = DataCatalog(datasets={
            >>>                   "cars": CSVDataset(filepath="cars.csv")
            >>>                  })
            >>> additional = {
            >>>     "planes": ParquetDataset("planes.parq"),
            >>>     "boats": CSVDataset(filepath="boats.csv")
            >>> }
            >>>
            >>> io.add_all(additional)
            >>>
            >>> assert io.list() == ["cars", "planes", "boats"]
        """
        for name, dataset in datasets.items():
            self.add(name, dataset, replace)

    def add_feed_dict(self, feed_dict: dict[str, Any], replace: bool = False) -> None:
        """Add datasets to the ``DataCatalog`` using the data provided through the `feed_dict`.

        `feed_dict` is a dictionary where the keys represent dataset names and the values can either be raw data or
        Kedro datasets - instances of classes that inherit from ``AbstractDataset``. If raw data is provided,
        it will be automatically wrapped in a ``MemoryDataset`` before being added to the ``DataCatalog``.

        Args:
            feed_dict: A dictionary with data to be added to the ``DataCatalog``. Keys are dataset names and
                values can be raw data or instances of classes that inherit from ``AbstractDataset``.
            replace: Specifies whether to replace an existing dataset with the same name in the ``DataCatalog``.

        Example:
        ::

            >>> from kedro_datasets.pandas import CSVDataset
            >>> import pandas as pd
            >>>
            >>> df = pd.DataFrame({"col1": [1, 2],
            >>>                    "col2": [4, 5],
            >>>                    "col3": [5, 6]})
            >>>
            >>> catalog = DataCatalog()
            >>> catalog.add_feed_dict({
            >>>     "data_df": df
            >>> }, replace=True)
            >>>
            >>> assert catalog.load("data_df").equals(df)
            >>>
            >>> csv_dataset = CSVDataset(filepath="test.csv")
            >>> csv_dataset.save(df)