diff --git a/.gitignore b/.gitignore index cfa1c1303..c010b0b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,9 @@ _trial_temp/ apidocs/ *.egg-info .eggs +.hypothesis + + +# Emacs temporary files +\#*.py# +.#*.py \ No newline at end of file diff --git a/pydoctor/driver.py b/pydoctor/driver.py index 1bf8b9cd1..72dd2e4a9 100644 --- a/pydoctor/driver.py +++ b/pydoctor/driver.py @@ -86,6 +86,7 @@ def make(system: model.System) -> None: """ Produce the html/intersphinx output, as configured in the system's options. """ + print('\n-- MAKE()') # DEBUG options = system.options # step 4: make html, if desired @@ -124,11 +125,23 @@ def make(system: model.System) -> None: subjects: Sequence[model.Documentable] = () if options.htmlsubjects: subjects = [system.allobjects[fn] for fn in options.htmlsubjects] + writer.writeIndividualFiles(subjects) else: + writer.writeIndividualFiles(subjects) writer.writeSummaryPages(system) + print('X'*100) + print(system.rootobjects) # DEBUG if not options.htmlsummarypages: subjects = system.rootobjects - writer.writeIndividualFiles(subjects) + print('Q'*100) + print(system.rootobjects) # DEBUG + # writer.writeIndividualFiles(subjects) + + # os.link( + # src=root_module_path, # original + # dst=root_module_path.parent / 'index.html' # the hardlink + # ) + if options.makeintersphinx: if not options.makehtml: diff --git a/pydoctor/templatewriter/writer.py b/pydoctor/templatewriter/writer.py index 06df1d5b4..d887a4999 100644 --- a/pydoctor/templatewriter/writer.py +++ b/pydoctor/templatewriter/writer.py @@ -2,6 +2,7 @@ from __future__ import annotations import itertools +import os from pathlib import Path from typing import IO, Iterable, Type, TYPE_CHECKING @@ -108,7 +109,16 @@ def writeSummaryPages(self, system: model.System) -> None: # not using missing_ok=True because that was only added in Python 3.8 and we still support Python 3.6 except FileNotFoundError: pass - root_module_path.symlink_to('index.html') + + # When support for Python 3.9 and older is dropped use + # pathlib.Path.hardlink_to() instead. + x = list(root_module_path.parent.glob('*')) + print(f'TTTT\n{root_module_path=} {x=}') + print(f'{root_module_path.exists()=}') + os.link( + src=root_module_path, # original + dst=root_module_path.parent / 'index.html' # the hardlink + ) def _writeDocsFor(self, ob: model.Documentable) -> None: if not ob.isVisible: diff --git a/pydoctor/test/test_commandline.py b/pydoctor/test/test_commandline.py index 7634b2138..c13da2263 100644 --- a/pydoctor/test/test_commandline.py +++ b/pydoctor/test/test_commandline.py @@ -215,6 +215,9 @@ def test_main_symlinked_paths(tmp_path: Path) -> None: link = tmp_path / 'src' link.symlink_to(Path.cwd(), target_is_directory=True) + print(f'{link=} {link.exists()=}') + print(f'{Path.cwd()=} {Path.cwd().exists()=}') + exit_code = driver.main(args=[ '--project-base-dir=.', '--html-viewsource-base=http://example.com', diff --git a/pydoctor/test/test_templatewriter.py b/pydoctor/test/test_templatewriter.py index 64a331474..61bd2fef2 100644 --- a/pydoctor/test/test_templatewriter.py +++ b/pydoctor/test/test_templatewriter.py @@ -139,11 +139,14 @@ def test_basic_package(tmp_path: Path) -> None: root, = system.rootobjects w._writeDocsFor(root) w.writeSummaryPages(system) + for ob in system.allobjects.values(): url = ob.url if '#' in url: url = url[:url.find('#')] + assert (tmp_path / url).is_file() + with open(tmp_path / 'basic.html', encoding='utf-8') as f: assert 'Package docstring' in f.read()