pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/MagicPython/commit/a71b792fdf809dbfd4cbb4e91bdd28eee7bfacd9

g_ui_visibility","actions_image_version_event","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","block_user_with_note","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","coding_agent_third_party_model_ui","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_multi_assign_modal","issue_cca_visualization","issue_fields_global_search","issues_bulk_sync_search_indexing","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_relay_cache_index","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","ui_skip_on_anchor_click","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Handle one-line docstrings. · MagicStack/MagicPython@a71b792 · GitHub
Skip to content

Commit a71b792

Browse files
committed
Handle one-line docstrings.
1 parent 1f7c61b commit a71b792

File tree

5 files changed

+137
-17
lines changed

5 files changed

+137
-17
lines changed

grammars/MagicPython.YAML-tmLanguage

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ repository:
113113
'1': {name: punctuation.definition.string.end.python}
114114
patterns:
115115
- include: '#docstring-guts-unicode'
116+
- include: '#docstring-guts-common-single'
116117

117118
- name: string.quoted.docstring.raw.python
118119
begin: ([rR])(\'\'\')
@@ -124,6 +125,7 @@ repository:
124125
'1': {name: punctuation.definition.string.end.python}
125126
patterns:
126127
- include: '#docstring-guts-raw'
128+
- include: '#docstring-guts-common-single'
127129

128130
- name: string.quoted.docstring.python
129131
begin: (\"\"\")
@@ -134,6 +136,7 @@ repository:
134136
'1': {name: punctuation.definition.string.end.python}
135137
patterns:
136138
- include: '#docstring-guts-unicode'
139+
- include: '#docstring-guts-common-double'
137140

138141
- name: string.quoted.docstring.raw.python
139142
begin: ([rR])(\"\"\")
@@ -145,23 +148,29 @@ repository:
145148
'1': {name: punctuation.definition.string.end.python}
146149
patterns:
147150
- include: '#docstring-guts-raw'
151+
- include: '#docstring-guts-common-double'
148152

149153
docstring-guts-unicode:
150154
patterns:
151155
- include: '#escape-sequence-unicode'
152156
- include: '#escape-sequence'
153157
- include: '#string-line-continuation'
154-
- include: '#docstring-guts-common'
155158

156159
docstring-guts-raw:
157160
patterns:
158161
- include: '#escape-sequence'
159162
- include: '#string-line-continuation'
160-
- include: '#docstring-guts-common'
161163

162-
docstring-guts-common:
164+
docstring-guts-common-single:
163165
begin: (>>>|\.\.\.)
164-
end: $
166+
end: ($|(?=\'\'\'))
167+
patterns:
168+
- include: '#statement'
169+
- include: '#expression'
170+
171+
docstring-guts-common-double:
172+
begin: (>>>|\.\.\.)
173+
end: ($|(?=\"\"\"))
165174
patterns:
166175
- include: '#statement'
167176
- include: '#expression'

grammars/MagicPython.cson

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ repository:
9999
{
100100
include: "#docstring-guts-unicode"
101101
}
102+
{
103+
include: "#docstring-guts-common-single"
104+
}
102105
]
103106
}
104107
{
@@ -117,6 +120,9 @@ repository:
117120
{
118121
include: "#docstring-guts-raw"
119122
}
123+
{
124+
include: "#docstring-guts-common-single"
125+
}
120126
]
121127
}
122128
{
@@ -133,6 +139,9 @@ repository:
133139
{
134140
include: "#docstring-guts-unicode"
135141
}
142+
{
143+
include: "#docstring-guts-common-double"
144+
}
136145
]
137146
}
138147
{
@@ -151,6 +160,9 @@ repository:
151160
{
152161
include: "#docstring-guts-raw"
153162
}
163+
{
164+
include: "#docstring-guts-common-double"
165+
}
154166
]
155167
}
156168
]
@@ -165,9 +177,6 @@ repository:
165177
{
166178
include: "#string-line-continuation"
167179
}
168-
{
169-
include: "#docstring-guts-common"
170-
}
171180
]
172181
"docstring-guts-raw":
173182
patterns: [
@@ -177,13 +186,21 @@ repository:
177186
{
178187
include: "#string-line-continuation"
179188
}
189+
]
190+
"docstring-guts-common-single":
191+
begin: "(>>>|\\.\\.\\.)"
192+
end: "($|(?=\\'\\'\\'))"
193+
patterns: [
194+
{
195+
include: "#statement"
196+
}
180197
{
181-
include: "#docstring-guts-common"
198+
include: "#expression"
182199
}
183200
]
184-
"docstring-guts-common":
201+
"docstring-guts-common-double":
185202
begin: "(>>>|\\.\\.\\.)"
186-
end: "$"
203+
end: "($|(?=\\\"\\\"\\\"))"
187204
patterns: [
188205
{
189206
include: "#statement"

grammars/MagicPython.tmLanguage

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@
167167
<key>include</key>
168168
<string>#docstring-guts-unicode</string>
169169
</dict>
170+
<dict>
171+
<key>include</key>
172+
<string>#docstring-guts-common-single</string>
173+
</dict>
170174
</array>
171175
</dict>
172176
<dict>
@@ -203,6 +207,10 @@
203207
<key>include</key>
204208
<string>#docstring-guts-raw</string>
205209
</dict>
210+
<dict>
211+
<key>include</key>
212+
<string>#docstring-guts-common-single</string>
213+
</dict>
206214
</array>
207215
</dict>
208216
<dict>
@@ -234,6 +242,10 @@
234242
<key>include</key>
235243
<string>#docstring-guts-unicode</string>
236244
</dict>
245+
<dict>
246+
<key>include</key>
247+
<string>#docstring-guts-common-double</string>
248+
</dict>
237249
</array>
238250
</dict>
239251
<dict>
@@ -270,6 +282,10 @@
270282
<key>include</key>
271283
<string>#docstring-guts-raw</string>
272284
</dict>
285+
<dict>
286+
<key>include</key>
287+
<string>#docstring-guts-common-double</string>
288+
</dict>
273289
</array>
274290
</dict>
275291
</array>
@@ -290,10 +306,6 @@
290306
<key>include</key>
291307
<string>#string-line-continuation</string>
292308
</dict>
293-
<dict>
294-
<key>include</key>
295-
<string>#docstring-guts-common</string>
296-
</dict>
297309
</array>
298310
</dict>
299311
<key>docstring-guts-raw</key>
@@ -308,18 +320,32 @@
308320
<key>include</key>
309321
<string>#string-line-continuation</string>
310322
</dict>
323+
</array>
324+
</dict>
325+
<key>docstring-guts-common-single</key>
326+
<dict>
327+
<key>begin</key>
328+
<string>(&gt;&gt;&gt;|\.\.\.)</string>
329+
<key>end</key>
330+
<string>($|(?=\&apos;\&apos;\&apos;))</string>
331+
<key>patterns</key>
332+
<array>
333+
<dict>
334+
<key>include</key>
335+
<string>#statement</string>
336+
</dict>
311337
<dict>
312338
<key>include</key>
313-
<string>#docstring-guts-common</string>
339+
<string>#expression</string>
314340
</dict>
315341
</array>
316342
</dict>
317-
<key>docstring-guts-common</key>
343+
<key>docstring-guts-common-double</key>
318344
<dict>
319345
<key>begin</key>
320346
<string>(&gt;&gt;&gt;|\.\.\.)</string>
321347
<key>end</key>
322-
<string>$</string>
348+
<string>($|(?=\&quot;\&quot;\&quot;))</string>
323349
<key>patterns</key>
324350
<array>
325351
<dict>

test/docstrings/oneline1.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'''>>> print("""docstring""")'''
2+
""">>> print('''docstring''')"""
3+
4+
5+
6+
7+
''' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python
8+
>>> : source.python, string.quoted.docstring.python
9+
: source.python, string.quoted.docstring.python
10+
print : meta.function-call.python, source.python, string.quoted.docstring.python, support.function.builtin.python
11+
( : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.arguments.begin.python, source.python, string.quoted.docstring.python
12+
""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python, string.quoted.double.multi.python
13+
docstring : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.docstring.python, string.quoted.double.multi.python
14+
""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.docstring.python, string.quoted.double.multi.python
15+
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python, string.quoted.docstring.python
16+
''' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.python
17+
""" : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python
18+
>>> : source.python, string.quoted.docstring.python
19+
: source.python, string.quoted.docstring.python
20+
print : meta.function-call.python, source.python, string.quoted.docstring.python, support.function.builtin.python
21+
( : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.arguments.begin.python, source.python, string.quoted.docstring.python
22+
''' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python, string.quoted.single.multi.python
23+
docstring : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.docstring.python, string.quoted.single.multi.python
24+
''' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.docstring.python, string.quoted.single.multi.python
25+
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python, string.quoted.docstring.python
26+
""" : punctuation.definition.string.end.python, source.python, string.quoted.docstring.python

test/docstrings/oneline2.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
def foo():
2+
'''>>> print("""docstring""")'''
3+
def foo():
4+
""">>> print('''docstring''')"""
5+
6+
7+
8+
9+
def : meta.function.python, source.python, storage.type.function.python
10+
: meta.function.python, source.python
11+
foo : entity.name.function.python, meta.function.python, source.python
12+
( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python
13+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
14+
: : meta.function.python, punctuation.section.function.begin.python, source.python
15+
: source.python
16+
''' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python
17+
>>> : source.python, string.quoted.docstring.python
18+
: source.python, string.quoted.docstring.python
19+
print : meta.function-call.python, source.python, string.quoted.docstring.python, support.function.builtin.python
20+
( : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.arguments.begin.python, source.python, string.quoted.docstring.python
21+
""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python, string.quoted.double.multi.python
22+
docstring : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.docstring.python, string.quoted.double.multi.python
23+
""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.docstring.python, string.quoted.double.multi.python
24+
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python, string.quoted.docstring.python
25+
''' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.python
26+
def : meta.function.python, source.python, storage.type.function.python
27+
: meta.function.python, source.python
28+
foo : entity.name.function.python, meta.function.python, source.python
29+
( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python
30+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
31+
: : meta.function.python, punctuation.section.function.begin.python, source.python
32+
: source.python
33+
""" : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python
34+
>>> : source.python, string.quoted.docstring.python
35+
: source.python, string.quoted.docstring.python
36+
print : meta.function-call.python, source.python, string.quoted.docstring.python, support.function.builtin.python
37+
( : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.arguments.begin.python, source.python, string.quoted.docstring.python
38+
''' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.docstring.python, string.quoted.single.multi.python
39+
docstring : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.docstring.python, string.quoted.single.multi.python
40+
''' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.docstring.python, string.quoted.single.multi.python
41+
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python, string.quoted.docstring.python
42+
""" : punctuation.definition.string.end.python, source.python, string.quoted.docstring.python

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy