Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api-docs: Update usage examples for stream to channel rename. #30135

Merged

Conversation

laurynmm
Copy link
Collaborator

Updates the Python and Javascript usage examples in the API documentation for the stream to channel rename.

Notes:

  • Focuses on updating descriptive text as function, endpoint and parameter/field names would be separate API changes if/when we decide to make them.
  • Updates some example strings used for channel names and some variable names.
  • For some Python usage examples, shows getting the value for a request field/parameter to improve clarity of example.

Example screenshots:

Get channel/stream ID endpoint

Current documentation
Screenshot from 2024-05-19 14-37-12
Screenshot from 2024-05-19 14-37-22

Update channel/stream enpoint

Current documentation
Screenshot from 2024-05-19 14-37-41

Update personal preferences for topic endpoint

Current documentation
Screenshot from 2024-05-19 14-37-56


Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@laurynmm laurynmm force-pushed the stream-to-channel-project-api-usage-examples branch 3 times, most recently from 1ef9365 to ed6b7ae Compare May 20, 2024 11:33
@laurynmm
Copy link
Collaborator Author

Updates:

  • Removed any changes that updated any of the Python usage examples to show getting a value (e.g. a channel ID) for a variable that's passed to the code example.
  • Made some revisions to some of the descriptive comments in the Python usage examples.

Updated screenshots:

Get channel/stream ID endpoint

Current documentation
Screenshot from 2024-05-20 13-42-04
Screenshot from 2024-05-20 13-42-11

Update a channel/stream endpoint

Current documentation
Screenshot from 2024-05-20 13-42-22

Update personal preferences for a topic endpoint

Current documentation
Screenshot from 2024-05-20 13-42-38

Not changed

  • Various Python usage examples have a stream_id variable that's used for the code example. It's possible that we want to update those to channel_id, but that could be confusing as the parameter named in the documentation is still uses "stream". See the example screenshots above for "Update a channel/stream" and "Update personal preferences ..." as examples of the current state.

@zulipbot
Copy link
Member

Hello @zulip/server-api members, this pull request was labeled with the "area: documentation (api and integrations)" label, so you may want to check it out!

@timabbott
Copy link
Sponsor Member

Regarding those stream_id parameters, I think probably we can leave those for a future pass following renaming stuff in python-zulip-api (with compatibility support), since then we can also change the function names called.

@@ -959,7 +963,8 @@ def render_message(client: Client) -> None:
@openapi_test_function("/messages:get")
def get_messages(client: Client) -> None:
# {code_example|start}
# Get the 100 last messages sent by "iago@zulip.com" to the stream "Verona"
# Get the 100 last messages sent by "iago@zulip.com" to
# channel named "Verona".
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to the channel"

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made several copyediting changes along these lines:

diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py
index c268fe39e3..60552c5788 100644
--- a/zerver/openapi/python_examples.py
+++ b/zerver/openapi/python_examples.py
@@ -691,7 +691,7 @@ def get_streams(client: Client) -> None:
 @openapi_test_function("/streams/{stream_id}:patch")
 def update_stream(client: Client, stream_id: int) -> None:
     # {code_example|start}
-    # Update channel, with a given channel ID.
+    # Update settings for the channel with a given ID.
     request = {
         "stream_id": stream_id,
         "stream_post_policy": 2,
@@ -800,7 +800,7 @@ def toggle_mute_topic(client: Client) -> None:
     )
 
     # {code_example|start}
-    # Mute the topic "boat party" in channel named "Denmark".
+    # Mute the topic "boat party" in the channel named "Denmark".
     request = {
         "stream": "Denmark",
         "topic": "boat party",
@@ -812,7 +812,7 @@ def toggle_mute_topic(client: Client) -> None:
     validate_against_openapi_schema(result, "/users/me/subscriptions/muted_topics", "patch", "200")
 
     # {code_example|start}
-    # Unmute the topic "boat party" in channel named "Denmark".
+    # Unmute the topic "boat party" in the channel named "Denmark".
     request = {
         "stream": "Denmark",
         "topic": "boat party",
@@ -902,7 +902,7 @@ def mark_all_as_read(client: Client) -> None:
 @openapi_test_function("/mark_stream_as_read:post")
 def mark_stream_as_read(client: Client) -> None:
     # {code_example|start}
-    # Mark the unread messages in channel with ID 1 as read.
+    # Mark the unread messages in the channel with ID 1 as read.
     result = client.mark_stream_as_read(1)
     # {code_example|end}
 
@@ -964,7 +964,7 @@ def render_message(client: Client) -> None:
 def get_messages(client: Client) -> None:
     # {code_example|start}
     # Get the 100 last messages sent by "iago@zulip.com" to
-    # channel named "Verona".
+    # the channel named "Verona".
     request: Dict[str, Any] = {
         "anchor": "newest",
         "num_before": 100,
@@ -1475,7 +1475,7 @@ def set_typing_status(client: Client) -> None:
 
     # {code_example|start}
     # The user has started to type in topic "typing status"
-    # of channel named "Denmark".
+    # of the channel named "Denmark".
     stream_id = client.get_stream_id("Denmark")["stream_id"]
     topic = "typing status"
 
@@ -1493,7 +1493,7 @@ def set_typing_status(client: Client) -> None:
 
     # {code_example|start}
     # The user has finished typing in topic "typing status"
-    # of channel named "Denmark".
+    # of the channel named "Denmark".
     stream_id = client.get_stream_id("Denmark")["stream_id"]
     topic = "typing status"
 

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and updating those!

Updates narrow parameters in the javascript and python usage
examples for the get_messages endpoint to use the "channel"
operator instead of the "stream" operator.

Part of the stream to channel rename project.
Updates comments that are displayed in the javascript examples for
various endpoints to use channel instead of stream.

Part of stream to channel rename project.
Even though there was a stream/channel ID being passed to the test
function for archive_stream, it wasn't being used in the test as
it was reset to a new stream created/subscribed in the function.

Updates the test function to remove the unused stream/channel ID
parameter, and updates the usage example for to use channel instead
of stream where appropriate.

Part of stream to channel rename project.
Renames the test channel created and used in python usage examples
to "python-test" instead of "new stream".

Part of stream to channel rename project.
Updates the channel names in python example tests to use "-channel"
instead of "_stream".

Part of stream to channel rename project.
Updates python usage example comments, which are user-facing, to
use channel instead of stream.

Part of the stream to channel rename project.
@timabbott timabbott force-pushed the stream-to-channel-project-api-usage-examples branch from ed6b7ae to c3577d9 Compare May 20, 2024 18:30
@timabbott timabbott merged commit c3577d9 into zulip:main May 20, 2024
4 of 5 checks passed
@timabbott
Copy link
Sponsor Member

Merged, after the small copyediting changes noted above, thanks @laurynmm!

@laurynmm laurynmm deleted the stream-to-channel-project-api-usage-examples branch May 21, 2024 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants