Repository: huggingface/huggingface_hub (python)

Issue:
Make it easier to modify the model card content
Modifying `card.text` does not modify `card.content`, which is what is pushed to the Hub.


```
card = ModelCard.load('akdeniz27/roberta-large-cuad')
card.text = """
This is the new model card
"""
card.content = str(card)
```

It would work, but it has the last unintuitive step of modifying `content. Ideally, when `text` is modified, the `content` should also be modified.

cc @nateraw 


Pull request description:
make repocard content a property
Resolves #1144 by turning `RepoCard.content` into a property with an accompanying setter fn. The setter handles setting `.data` and `.text` attributes accordingly. 

This way, when you update the card text or data, the card's content will be updated as well. As an added bonus, if you update `card.content`, it will update the card data and text as well. 

Patch:
diff --git a/docs/source/how-to-manage.mdx b/docs/source/how-to-manage.mdx
index 312f36d2..b9157236 100644
--- a/docs/source/how-to-manage.mdx
+++ b/docs/source/how-to-manage.mdx
@@ -45,7 +45,7 @@ By default, [`create_repo`] creates a model repository. But you can use the `rep
 ```py
 >>> from huggingface_hub import create_repo
 >>> create_repo("lysandre/test-dataset", repo_type="dataset")
-'https://huggingface.co/lysandre/test-dataset'
+'https://huggingface.co/datasets/lysandre/test-dataset'
 ```
 
 When you create a repository, you can set your repository visibility with the `private` parameter. For example, if you want to create a private repository:
diff --git a/src/huggingface_hub/repocard.py b/src/huggingface_hub/repocard.py
index 7fb536ed..b7cbc25a 100644
--- a/src/huggingface_hub/repocard.py
+++ b/src/huggingface_hub/repocard.py
@@ -79,7 +79,22 @@ class RepoCard:
 
         </Tip>
         """
+
+        # Set the content of the RepoCard, as well as underlying .data and .text attributes.
+        # See the `content` property setter for more details.
         self.content = content
+
+    @property
+    def content(self):
+        """The content of the RepoCard, including the YAML block and the Markdown body."""
+        line_break = _detect_line_ending(self._content) or "\n"
+        return f"---{line_break}{self.data.to_yaml(line_break=line_break)}{line_break}---{line_break}{self.text}"
+
+    @content.setter
+    def content(self, content: str):
+        """Set the content of the RepoCard."""
+        self._content = content
+
         match = REGEX_YAML_BLOCK.search(content)
         if match:
             # Metadata found in the YAML block
@@ -101,8 +116,7 @@ class RepoCard:
         self.data = self.card_data_class(**data_dict)
 
     def __str__(self):
-        line_break = _detect_line_ending(self.content) or "\n"
-        return f"---{line_break}{self.data.to_yaml(line_break=line_break)}{line_break}---{line_break}{self.text}"
+        return self.content
 
     def save(self, filepath: Union[Path, str]):
         r"""Save a RepoCard to a file.


Test patch:
diff --git a/tests/test_repocard.py b/tests/test_repocard.py
index 1cda3d7e..dba14949 100644
--- a/tests/test_repocard.py
+++ b/tests/test_repocard.py
@@ -656,6 +656,14 @@ class RepoCardTest(TestCaseWithCapLog):
         card = RepoCard.load(card_path)
         self.assertIn("\r\n", str(card))
 
+    def test_updating_text_updates_content(self):
+        sample_path = SAMPLE_CARDS_DIR / "sample_simple.md"
+        card = RepoCard.load(sample_path)
+        card.text = "Hello, world!"
+        self.assertEqual(
+            card.content, f"---\n{card.data.to_yaml()}\n---\nHello, world!"
+        )
+
 
 class ModelCardTest(TestCaseWithCapLog):
     def test_model_card_with_invalid_model_index(self):