Coverage for sources/librovore/structures/sphinx/patterns.py: 100%

3 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-09-28 22:09 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Universal Sphinx documentation patterns based on empirical analysis. ''' 

22 

23 

24from . import __ 

25 

26 

27UNIVERSAL_PATTERNS: __.cabc.Mapping[ 

28 str, __.cabc.Mapping[ str, __.typx.Any ] 

29] = __.immut.Dictionary( { 

30 'code_blocks': __.immut.Dictionary( { 

31 'container_selector': '.highlight', 

32 'language_detection': __.immut.Dictionary( { 

33 'method': 'parent_class_prefix', 

34 'prefix': 'highlight-', 

35 'language_map': __.immut.Dictionary( { 

36 'default': '', 

37 'text': '', 

38 'python': 'python', 

39 'json': 'json', 

40 'javascript': 'javascript', 

41 'bash': 'bash', 

42 'yaml': 'yaml', 

43 'py': 'python', 

44 'js': 'javascript', 

45 'sh': 'bash', 

46 'shell': 'bash', 

47 'console': 'bash', 

48 'yml': 'yaml', 

49 } ), 

50 } ), 

51 } ), 

52 'api_signatures': __.immut.Dictionary( { 

53 'signature_selector': 'dt.sig.sig-object.py', 

54 'description_selector': 'dd', 

55 'signature_classes': [ 'sig', 'sig-object', 'py' ], 

56 'signature_roles': [ 'function', 'class', 'method', 'attribute' ], 

57 } ), 

58 'content_containers': __.immut.Dictionary( { 

59 'universal_selectors': [ 

60 'article[role="main"]', 

61 'main[role="main"]', 

62 'div.body[role="main"]', 

63 ], 

64 # 'generic_fallback': [ 

65 # 'div.body[role="main"]', 'section', 'div.content', 

66 # 'article[role="main"]' 

67 # ], 

68 } ), 

69 'navigation_cleanup': __.immut.Dictionary( { 

70 'universal_selectors': [ 

71 'nav', '.navigation', '.sidebar', '.toc', 'a.headerlink' 

72 ], 

73 } ), 

74} ) 

75 

76 

77THEME_PATTERNS: __.cabc.Mapping[ 

78 str, __.cabc.Mapping[ str, __.cabc.Sequence[ str ] ] 

79] = __.immut.Dictionary( { 

80 'content_containers': __.immut.Dictionary( { 

81 'furo': [ 'article[role="main"]', 'div.content', 'section' ], 

82 'sphinx_rtd_theme': [ 'section.wy-nav-content-wrap', 'section' ], 

83 'pydata_sphinx_theme': [ 

84 'main.bd-main', 'article.bd-article', 'section' 

85 ], 

86 'python_docs_theme': [ 'div.body[role="main"]', 'section' ], 

87 'alabaster': [ 'div.body[role="main"]', 'section' ], 

88 'agogo': [ 'div.body[role="main"]', 'div.content', 'section' ], 

89 'classic': [ 'div.body[role="main"]', 'section' ], 

90 'nature': [ 'div.body[role="main"]', 'section' ], 

91 } ), 

92 'navigation_cleanup': __.immut.Dictionary( { 

93 'sphinx_rtd_theme': [ 'nav.wy-nav-side', 'nav.wy-nav-top' ], 

94 'pydata_sphinx_theme': [ 'nav.bd-docs-nav', 'nav.d-print-none' ], 

95 'python_docs_theme': [ 'nav.menu', 'nav.nav-content' ], 

96 'agogo': [ 'div.sidebar' ], 

97 } ), 

98} )