MCPcopy Create free account
hub / github.com/crewAIInc/crewAI / _build_edge_entry

Function _build_edge_entry

scripts/docs/prefix_version_paths.py:116–142  ·  view source on GitHub ↗

Clone the current default version's nav structure into an Edge entry whose page paths are prefixed with ``edge/ /`` so Edge serves at ``/edge/ /...`` URLs and never collides with the canonical ``/ /...`` URLs that wildcard redirects own.

(latest_entry: dict, locale: str)

Source from the content-addressed store, hash-verified

114
115
116def _build_edge_entry(latest_entry: dict, locale: str) -> dict:
117 """Clone the current default version's nav structure into an Edge entry
118 whose page paths are prefixed with ``edge/<locale>/`` so Edge serves at
119 ``/edge/<locale>/...`` URLs and never collides with the canonical
120 ``/<locale>/...`` URLs that wildcard redirects own.
121 """
122 edge = copy.deepcopy(latest_entry)
123 edge["version"] = EDGE_VERSION
124 edge["tag"] = EDGE_TAG
125 edge.pop("default", None)
126 # The cloned entry's page paths are still ``<version_slug>/<locale>/...``
127 # from the source. Swap the version segment for ``edge``.
128 source_prefix = re.compile(rf"^{re.escape(latest_entry['version'])}/")
129 locale_prefix = f"{locale}/"
130 edge_prefix = f"{EDGE_PREFIX}/"
131
132 def transform(page: str) -> str:
133 if page.startswith(edge_prefix):
134 return page
135 rewritten = source_prefix.sub(edge_prefix, page)
136 if rewritten != page:
137 return rewritten
138 if page.startswith(locale_prefix):
139 return f"{edge_prefix}{page}"
140 return page
141
142 return _walk_pages(edge, transform)
143
144
145def _migrate_language_block(block: dict, docs_root: Path) -> dict:

Callers 1

_migrate_language_blockFunction · 0.85

Calls 2

popMethod · 0.80
_walk_pagesFunction · 0.70

Tested by

no test coverage detected