Skip to content
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

Fix of pydoctor crash when creating symlink to index.html #809

Merged
merged 16 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pydoctor/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def make(system: model.System) -> None:
if not options.htmlsummarypages:
subjects = system.rootobjects
writer.writeIndividualFiles(subjects)
writer.writeIndexSymlink(system)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you try this with option --html-subjects ? It seems that it will run into the same error because we don't generate index.html in these cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right. There needs to be an if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


if options.makeintersphinx:
if not options.makehtml:
Expand Down
5 changes: 3 additions & 2 deletions pydoctor/templatewriter/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def writeSummaryPages(self, system: model.System) -> None:
T = time.time()
search.write_lunr_index(self.build_directory, system=system)
system.msg('html', "took %fs"%(time.time() - T), wantsnl=False)


def writeIndexSymlink(self, system: model.System) -> None:
if len(system.root_names) == 1:
# If there is just a single root module it is written to index.html to produce nicer URLs.
# To not break old links we also create a symlink from the full module name to the index.html
Expand All @@ -107,7 +108,7 @@ def writeSummaryPages(self, system: model.System) -> None:
root_module_path.unlink()
# not using missing_ok=True because that was only added in Python 3.8 and we still support Python 3.6
except FileNotFoundError:
pass
system.msg('file not found:', root_module_path)
rocketengineer1982 marked this conversation as resolved.
Show resolved Hide resolved
root_module_path.symlink_to('index.html')

def _writeDocsFor(self, ob: model.Documentable) -> None:
Expand Down