DOP-5816: Avoid parsing txt files in reserved directories#669
Conversation
seungpark
left a comment
There was a problem hiding this comment.
LGTM 👍 thanks for the insightful test!
|
Awesome - looks like this captures the behavior we want. Thank you for investigating the related cases! LGTM 🚢 |
| PAT_URI = re.compile(r"^(?P<schema>[a-z]+)://") | ||
| SOURCE_FILE_EXTENSIONS = {".txt", ".rst", ".yaml"} | ||
| RST_EXTENSIONS = {".txt", ".rst"} | ||
| RESERVED_DIRS = {"code-examples"} |
There was a problem hiding this comment.
Not a huge deal because eventually the parser will be going away, but I would have loved for this to have been defined by the user (let's say in snooty.toml). Things like this can make the platform more "brittle"
There was a problem hiding this comment.
I agree. I made this a set to begin with to allow for that flexibility if needed. The reason why it wasn't implemented here was for convenience and consistency since this seems like desired behavior across all docs sites. If this assumption is or becomes false, I'd recommend creating a follow-up to this accordingly.
Ticket
DOP-5816
Notes
Currently, the parser assumes that any
txtfile should be parsed as reStructuredText and be counted as a page. This PR makes it so that thecode-examplesdirectory is treated as a special directory name reserved for code examples, and not pages.I created a staging link that did not result in any orphan page errors:
This is the following behavior:
txtfile nested in anycode-examplessubdirectory as reStructuredText.find . -type f \( -name "*.txt" \) -print0 | grep -z "code-examples" | xargs -0 -I {} realpath {}across the subdirectories I had locally, and it shouldn't (unless my content repos were severely out-of-date).txtfile in anycode-examplessubdirectory, regardless of nesting level.rstfile nested in anycode-examplessubdirectory as reStructuredText.code-exampleswithrstfiles, such as server manual.txtfile that is calledcode-examples.txt(unless it’s nested in somecode-examplessubdirectory).README updates