-
Notifications
You must be signed in to change notification settings - Fork 93
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
Support nested pages (python.py) #163
base: master
Are you sure you want to change the base?
Conversation
What works: template-generated paths (css, js, navbar, etc.) What doesnt: pretty much all rest, including rst-generated urls, breadcrumb, pages hierarchy
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
==========================================
- Coverage 98.25% 98.22% -0.03%
==========================================
Files 27 27
Lines 6647 6716 +69
Branches 44 44
==========================================
+ Hits 6531 6597 +66
- Misses 116 119 +3
Continue to review full report at Codecov.
|
The only change is path with '/' first searched in name_map, if not found return as is
@@ -264,7 +264,7 @@ def serialize(self, merge_prefixes=True) -> bytearray: | |||
if e.flags & ResultFlag.HAS_SUFFIX: | |||
output += self.suffix_length_struct.pack(e.suffix_length) | |||
output += e.name.encode('utf-8') | |||
if e.url: | |||
if e.name and e.url: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change made to match above lines (250-251):
if e.name and e.url:
offset += len(e.url.encode('utf-8')) + 1
Could be it should be turned around.
_url_formatter = None | ||
_external_data = set() | ||
# A helper function to work-around for stateless Docutils transforms | ||
def get_image_extracter(source, external_data:set, config): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every function call generates new class with captured function parameters, a work-around stateless transform limitation.
Not perfect, but probably not a big overhead in python realm.
I've mocked this usage pattern to measure memory footprint. It turned out that python is able to garbage collect most of unused classes as long as they are not referenced from elsewhere.
Here is test and measurement result: https://gist.github.com/sizmailov/93cb521557dd64019598554626defe23
Note: rightmost column can be turned to zeros via extra gc.collect()
call
image_abs_path = os.path.realpath(os.path.join(os.path.dirname(source), image['uri'])) | ||
# Use relative path if image within INPUT directory, otherwise absolute | ||
if image_abs_path.startswith(input_path): | ||
image_path = os.path.relpath(image_abs_path, input_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This always returns relative path to INPUT directory, will be patched later by PatchReferences
This PR adds basic support for nested pages for
python.py
.Changes:
default_url_formatter
-generated.html
tree structure mirrors input.rst
layout../*
prefix prepended to references and image sources in nested pages (both.rst
-generated code and in templates)I use relative paths because it would make possible to place C++ and Python API on same domain.
TODO:
Show nested structure inpages
Copy images with relative paths to avoid clashesAvoid clearing jinja cacheSearch results