Coverage for lode / helpers / links.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-11-22 15:54 +0000

1"""Where the things a page links to live: what a viewer cannot know by itself.""" 

2from typing import Optional 

3 

4 

5class Links: 

6 """Tell a viewer the addresses of resources, exports and the whole artefact. 

7 

8 The web service and the static site each know where these live (a query string, a relative 

9 path); the viewer does not. This base class answers "nowhere": every method returns None, which 

10 is what a library user without a site gets. A caller subclasses it and answers. 

11 """ 

12 

13 def resource(self, iri: str) -> Optional[str]: 

14 """Return the address of the page of a resource of this documentation, or None when it has no page here: the viewer then links to the IRI itself.""" 

15 return None 

16 

17 def export(self, ext: str, iri: Optional[str] = None) -> Optional[str]: 

18 """Return where to download the artefact, or the resource `iri`, in the format with extension `ext`.""" 

19 return None 

20 

21 def home(self) -> Optional[str]: 

22 """Return the address of the page of the whole artefact, or None.""" 

23 return None 

24 

25 def visualize(self, iri: str) -> Optional[str]: 

26 """Return the address that opens the documentation of another ontology, or None. 

27 

28 Only the service can do it (it reads and renders on request); a static site cannot. 

29 """ 

30 return None 

31