@@ -564,30 +564,30 @@ def retrieve_whatsnew_input(app: Sphinx) -> tuple:
564
564
# The source directory of the documentation: {repository_root}/doc/source
565
565
doc_src_dir = app .env .srcdir
566
566
567
- # Get the number of headers to display in the what's new section in the sidebar
568
- # By default, it's 3
569
- no_of_headers = whatsnew_options .get ("no_of_headers" , 3 )
570
- # Get the number of what's new content to display under each minor version in the sidebar.
571
- # By default, it's 3
572
- no_of_contents = whatsnew_options .get ("no_of_contents" , None )
573
-
574
- # Get the name of the whatsnew.yml file in doc/source. By default, it's "whatsnew"
575
- whatsnew_file = whatsnew_options .get ("whatsnew_file" , "whatsnew" )
567
+ # Get the name of the whatsnew.yml file in doc/source
568
+ whatsnew_file = whatsnew_options .get ("whatsnew_file_name" , None )
576
569
whatsnew_file = pathlib .Path (doc_src_dir ) / f"{ whatsnew_file } .yml"
577
570
578
- # Get the name of the changelog file in doc/source. By default, it's "changelog"
579
- changelog_file = whatsnew_options .get ("changelog_file " , "changelog" )
571
+ # Get the name of the changelog file in doc/source
572
+ changelog_file = whatsnew_options .get ("changelog_file_name " , None )
580
573
changelog_file = pathlib .Path (doc_src_dir ) / f"{ changelog_file } .rst"
581
574
582
- # Get the pages the whatsnew section should be displayed on. By default, it's changelog
583
- pages = whatsnew_options .get ("pages" , ["changelog" ])
575
+ # Get the pages the whatsnew section should be displayed on
576
+ pages = whatsnew_options .get ("sidebar_pages" , None )
577
+
578
+ # Get the number of headers to display in the what's new section in the sidebar
579
+ # By default, it displays the first three minor versions
580
+ no_of_headers = whatsnew_options .get ("sidebar_no_of_headers" , 3 )
581
+ # Get the number of what's new content to display under each minor version in the sidebar.
582
+ # By default, it displays all what's new dropdown titles
583
+ no_of_contents = whatsnew_options .get ("sidebar_no_of_contents" , None )
584
584
585
585
whatsnew_config = {
586
- "no_of_headers" : no_of_headers ,
587
- "no_of_contents" : no_of_contents ,
588
586
"whatsnew_file" : whatsnew_file ,
589
587
"changelog_file" : changelog_file ,
590
588
"pages" : pages ,
589
+ "no_of_headers" : no_of_headers ,
590
+ "no_of_contents" : no_of_contents ,
591
591
}
592
592
593
593
return whatsnew_config
@@ -601,6 +601,10 @@ def add_whatsnew_changelog(app, doctree):
601
601
if not whatsnew_config :
602
602
return
603
603
604
+ # Skip this function if the what's new file or changelog file were not provided
605
+ if not whatsnew_config ["whatsnew_file" ] or not whatsnew_config ["changelog_file" ]:
606
+ return
607
+
604
608
# Read the file and get the sections from the file as a list. For example,
605
609
# sections = [<document: <target...><section "getting started; ref-getting-starte ...>]
606
610
sections = doctree .traverse (nodes .document )
@@ -934,6 +938,15 @@ def extract_whatsnew(app, doctree, docname):
934
938
if not whatsnew_config :
935
939
return
936
940
941
+ # Skip this function if the what's new file or changelog file were not provided
942
+ if not whatsnew_config ["whatsnew_file" ] or not whatsnew_config ["changelog_file" ]:
943
+ return
944
+
945
+ # Skip this function if the "sidebar_pages" list is not provided in the whatsnew config
946
+ if not whatsnew_config ["pages" ]:
947
+ return
948
+
949
+ # Skip this function if the docname is not in the "sidebar_pages" list
937
950
if docname not in whatsnew_config ["pages" ]:
938
951
return
939
952
0 commit comments