Coverage for website/build.py: 93%

28 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-08 06:03 +0000

1#!/usr/bin/env python3 

2""" 

3Website Builder - Re-export Module. 

4 

5This module provides comprehensive website building functionality through a clean, 

6modular architecture. The original WebsiteBuilder class and its methods have been 

7extracted to the 'builder' sub-package for better maintainability and testability. 

8 

9Architecture: 

10- builder.core: Main WebsiteBuilder class with lifecycle management 

11- builder.templates: Template loading and placeholder processing 

12- builder.markdown: Markdown-to-HTML conversion with extensions 

13- builder.assets: Asset management and static file handling 

14""" 

15 

16import argparse 

17 

18# Re-export the main WebsiteBuilder class for backward compatibility 

19# Handle both relative import (when used as module) and absolute import (when run as script) 

20try: 

21 from .builder.core import WebsiteBuilder 

22except ImportError: 

23 # Fallback for when script is run directly 

24 import sys 

25 from pathlib import Path 

26 

27 sys.path.insert(0, str(Path(__file__).parent)) 

28 from builder.core import WebsiteBuilder 

29 

30 

31def main(): 

32 """Main entry point.""" 

33 parser = argparse.ArgumentParser( 

34 description="Build QDrant Loader documentation website" 

35 ) 

36 parser.add_argument("--output", "-o", default="site", help="Output directory") 

37 parser.add_argument( 

38 "--templates", "-t", default="website/templates", help="Templates directory" 

39 ) 

40 parser.add_argument("--coverage-artifacts", help="Coverage artifacts directory") 

41 parser.add_argument("--test-results", help="Test results directory") 

42 parser.add_argument("--base-url", default="", help="Base URL for the website") 

43 

44 args = parser.parse_args() 

45 

46 builder = WebsiteBuilder(args.templates, args.output) 

47 builder.base_url = args.base_url 

48 # Mark that base_url came from CLI (even if empty string). Avoid auto-overrides. 

49 try: 

50 builder.base_url_user_set = True 

51 except Exception: 

52 pass 

53 

54 try: 

55 builder.build_site(args.coverage_artifacts, args.test_results) 

56 except Exception as e: 

57 print(f"❌ Build failed: {e}") 

58 return 1 

59 

60 return 0 

61 

62 

63if __name__ == "__main__": 

64 exit(main())