@@ -893,6 +893,62 @@ def test_banner() -> None:
893893 )
894894
895895
896+ def test_cta_banner () -> None :
897+ path = ROOT_PATH .joinpath (Path ("test.rst" ))
898+ project_config = ProjectConfig (ROOT_PATH , "" , source = "./" )
899+ parser = rstparser .Parser (project_config , JSONVisitor )
900+
901+ # Test valid cta-banner
902+ page , diagnostics = parse_rst (
903+ parser ,
904+ path ,
905+ """
906+ .. cta-banner::
907+ :url: https://university.mongodb.com/
908+
909+ If you prefer learning through videos, try this lesson on `MongoDB University
910+ <https://university.mongodb.com/>`_
911+ """ ,
912+ )
913+ page .finish (diagnostics )
914+ assert diagnostics == []
915+ check_ast_testing_string (
916+ page .ast ,
917+ """<root fileid="test.rst">
918+ <directive domain="mongodb" name="cta-banner" url="https://university.mongodb.com/">
919+ <paragraph><text>If you prefer learning through videos, try this lesson on </text>
920+ <reference refuri="https://university.mongodb.com/"><text>MongoDB University</text></reference>
921+ <named_reference refname="MongoDB University" refuri="https://university.mongodb.com/"></named_reference>
922+ </paragraph>
923+ </directive></root>""" ,
924+ )
925+
926+ # Test cta-banner without url option specified
927+ page , diagnostics = parse_rst (
928+ parser ,
929+ path ,
930+ """
931+ .. cta-banner::
932+
933+ If you prefer learning through videos, try this lesson on `MongoDB University
934+ <https://university.mongodb.com/>`_
935+ """ ,
936+ )
937+ page .finish (diagnostics )
938+ assert len (diagnostics ) == 1
939+ assert isinstance (diagnostics [0 ], DocUtilsParseError )
940+ check_ast_testing_string (
941+ page .ast ,
942+ """<root fileid="test.rst">
943+ <directive domain="mongodb" name="cta-banner">
944+ <paragraph><text>If you prefer learning through videos, try this lesson on </text>
945+ <reference refuri="https://university.mongodb.com/"><text>MongoDB University</text></reference>
946+ <named_reference refname="MongoDB University" refuri="https://university.mongodb.com/"></named_reference>
947+ </paragraph>
948+ </directive></root>""" ,
949+ )
950+
951+
896952def test_rst_replacement () -> None :
897953 path = ROOT_PATH .joinpath (Path ("test.rst" ))
898954 project_config = ProjectConfig (ROOT_PATH , "" , source = "./" )
0 commit comments