Coverage for sources/librovore/structures/mkdocs/main.py: 27%

22 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''' MkDocs documentation structure processor main implementation. ''' 

22 

23 

24from . import __ 

25from . import detection as _detection 

26 

27 

28class MkDocsProcessor( __.Processor ): 

29 ''' Documentation processor for MkDocs sites with mkdocstrings. ''' 

30 

31 name: str = 'mkdocs' 

32 

33 @property 

34 def capabilities( self ) -> __.ProcessorCapabilities: 

35 ''' Returns MkDocs structure processor capabilities. ''' 

36 return __.ProcessorCapabilities( 

37 processor_name = self.name, 

38 version = '1.0.0', 

39 supported_filters = [ ], 

40 results_limit_max = 1000, 

41 response_time_typical = 'fast', 

42 notes = 'Processes MkDocs site structure and themes' 

43 ) 

44 

45 async def detect( 

46 self, auxdata: __.ApplicationGlobals, source: str 

47 ) -> _detection.MkDocsDetection: 

48 ''' Detects MkDocs documentation structure from source. ''' 

49 base_url = __.normalize_base_url( source ) 

50 normalized_source = base_url.geturl( ) 

51 confidence = 0.0 

52 has_mkdocs_yml = ( 

53 await _detection.check_mkdocs_yml( auxdata, base_url ) ) 

54 if has_mkdocs_yml: 

55 confidence += 0.6 

56 theme_metadata = ( 

57 await _detection.detect_theme( auxdata, base_url ) ) 

58 theme = theme_metadata.get( 'theme' ) 

59 if theme is not None: 

60 confidence += 0.3 

61 mkdocs_html_confidence = ( 

62 await _detection.check_mkdocs_html_markers( auxdata, base_url ) ) 

63 confidence += mkdocs_html_confidence 

64 confidence = min( confidence, 1.0 ) 

65 

66 return _detection.MkDocsDetection( 

67 processor = self, 

68 confidence = confidence, 

69 source = source, 

70 has_mkdocs_yml = has_mkdocs_yml, 

71 normalized_source = normalized_source, 

72 theme = theme ) 

73