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

3 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-20 18:40 +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 MkDocs 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': 'element_class_prefix', 

34 'prefix': 'language-', 

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

36 'py': 'python', 

37 'js': 'javascript', 

38 'yml': 'yaml', 

39 'console': 'bash', 

40 'shell': 'bash', 

41 'bash': 'bash', 

42 'sh': 'bash', 

43 'python': 'python', 

44 'javascript': 'javascript', 

45 'yaml': 'yaml', 

46 'json': 'json', 

47 } ), 

48 } ), 

49 } ), 

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

51 'mkdocstrings': __.immut.Dictionary( { 

52 'signature_container': 'div.autodoc', 

53 'signature_element': 'div.autodoc-signature', 

54 'docstring_element': 'div.autodoc-docstring', 

55 'function_name_selector': 'code > strong', 

56 'parameters_selector': 'em.autodoc-param', 

57 'signature_roles': [ 'function', 'class', 'method' ], 

58 } ), 

59 } ), 

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

61 'universal_selectors': [ 

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

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

64 ], 

65 # 'generic_fallback': [ 

66 # 'main', 'article', '[role="main"]', '.md-content', '.container' 

67 # ], 

68 } ), 

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

70 'universal_selectors': [ 

71 'nav', '.navbar', '.navigation', '.sidebar' 

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 'material': [ 

82 'main.md-main', 'article.md-content__inner', 'div.md-content' 

83 ], 

84 'readthedocs': [ 'div.col-md-9[role="main"]', 'div.container' ], 

85 'mkdocs_default': [ 'div.col-md-9[role="main"]', 'div.container' ], 

86 } ), 

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

88 'material': [ 'nav.md-nav', 'div.md-sidebar', 'nav.md-header__inner' ], 

89 'readthedocs': [ 'div.navbar', 'ul.nav.navbar-nav' ], 

90 'mkdocs_default': [ 'div.navbar', 'ul.nav.navbar-nav' ], 

91 } ), 

92} )