mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	integrations-docs: Move markdown macros include files.
Moves files in `templates/zerver/help/include` that are used specifically for integrations documentation to be in a new directory: `templates/zerver/integrations/include`. Adds a boolean parameter to `render_markdown_path` to be used for integrations documentation pages.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							53f705c7bd
						
					
				
				
					commit
					5f9dc76d54
				
			@@ -64,7 +64,7 @@ phrases and steps at the location of the macros. Macros help eliminate
 | 
				
			|||||||
repeated content in our documentation.
 | 
					repeated content in our documentation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The source for macros is the Markdown files under
 | 
					The source for macros is the Markdown files under
 | 
				
			||||||
`templates/zerver/help/include` in the
 | 
					`templates/zerver/integrations/include/` in the
 | 
				
			||||||
[main Zulip server repository](https://github.com/zulip/zulip). If you find
 | 
					[main Zulip server repository](https://github.com/zulip/zulip). If you find
 | 
				
			||||||
multiple instances of particular content in the documentation, you can
 | 
					multiple instances of particular content in the documentation, you can
 | 
				
			||||||
always create a new macro by adding a new file to that folder.
 | 
					always create a new macro by adding a new file to that folder.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,7 +83,10 @@ docs_without_macros = [
 | 
				
			|||||||
@items_tuple_to_dict
 | 
					@items_tuple_to_dict
 | 
				
			||||||
@register.filter(name="render_markdown_path", is_safe=True)
 | 
					@register.filter(name="render_markdown_path", is_safe=True)
 | 
				
			||||||
def render_markdown_path(
 | 
					def render_markdown_path(
 | 
				
			||||||
    markdown_file_path: str, context: Optional[Dict[str, Any]] = None, pure_markdown: bool = False
 | 
					    markdown_file_path: str,
 | 
				
			||||||
 | 
					    context: Optional[Dict[str, Any]] = None,
 | 
				
			||||||
 | 
					    pure_markdown: bool = False,
 | 
				
			||||||
 | 
					    integration_doc: bool = False,
 | 
				
			||||||
) -> str:
 | 
					) -> str:
 | 
				
			||||||
    """Given a path to a Markdown file, return the rendered HTML.
 | 
					    """Given a path to a Markdown file, return the rendered HTML.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -127,10 +130,6 @@ def render_markdown_path(
 | 
				
			|||||||
            zerver.lib.markdown.help_relative_links.makeExtension(),
 | 
					            zerver.lib.markdown.help_relative_links.makeExtension(),
 | 
				
			||||||
            zerver.lib.markdown.help_emoticon_translations_table.makeExtension(),
 | 
					            zerver.lib.markdown.help_emoticon_translations_table.makeExtension(),
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    if md_macro_extension is None:
 | 
					 | 
				
			||||||
        md_macro_extension = zerver.lib.markdown.include.makeExtension(
 | 
					 | 
				
			||||||
            base_path="templates/zerver/help/include/"
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
    if "api_url" in context:
 | 
					    if "api_url" in context:
 | 
				
			||||||
        # We need to generate the API code examples extension each
 | 
					        # We need to generate the API code examples extension each
 | 
				
			||||||
        # time so the `api_url` config parameter can be set dynamically.
 | 
					        # time so the `api_url` config parameter can be set dynamically.
 | 
				
			||||||
@@ -146,6 +145,14 @@ def render_markdown_path(
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        extensions = md_extensions
 | 
					        extensions = md_extensions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if integration_doc:
 | 
				
			||||||
 | 
					        md_macro_extension = zerver.lib.markdown.include.makeExtension(
 | 
				
			||||||
 | 
					            base_path="templates/zerver/integrations/include/"
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        md_macro_extension = zerver.lib.markdown.include.makeExtension(
 | 
				
			||||||
 | 
					            base_path="templates/zerver/help/include/"
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
    if not any(doc in markdown_file_path for doc in docs_without_macros):
 | 
					    if not any(doc in markdown_file_path for doc in docs_without_macros):
 | 
				
			||||||
        extensions = [md_macro_extension, *extensions]
 | 
					        extensions = [md_macro_extension, *extensions]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -325,6 +325,6 @@ def integration_doc(request: HttpRequest, integration_name: str = REQ()) -> Http
 | 
				
			|||||||
    if isinstance(integration, HubotIntegration):
 | 
					    if isinstance(integration, HubotIntegration):
 | 
				
			||||||
        context["hubot_docs_url"] = integration.hubot_docs_url
 | 
					        context["hubot_docs_url"] = integration.hubot_docs_url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    doc_html_str = render_markdown_path(integration.doc, context)
 | 
					    doc_html_str = render_markdown_path(integration.doc, context, integration_doc=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return HttpResponse(doc_html_str)
 | 
					    return HttpResponse(doc_html_str)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user