@@ -83,48 +83,48 @@ def process_needlist(app: Sphinx, doctree: nodes.document, fromdocname: str, fou
83
83
all_needs = list (SphinxNeedsData (env ).get_or_create_needs ().values ())
84
84
found_needs = process_filters (app , all_needs , current_needfilter )
85
85
86
- line_block = nodes .line_block ()
87
-
88
- # Add lineno to node
89
- line_block .line = current_needfilter ["lineno" ]
90
- for need_info in found_needs :
91
- para = nodes .line ()
92
- description = "{}: {}" .format (need_info ["id" ], need_info ["title" ])
93
-
94
- if current_needfilter ["show_status" ] and need_info ["status" ]:
95
- description += " (%s)" % need_info ["status" ]
96
-
97
- if current_needfilter ["show_tags" ] and need_info ["tags" ]:
98
- description += " [%s]" % "; " .join (need_info ["tags" ])
99
-
100
- title = nodes .Text (description )
101
-
102
- # Create a reference
103
- if need_info ["hide" ]:
104
- para += title
105
- elif need_info ["is_external" ]:
106
- assert need_info ["external_url" ] is not None , "External need without URL"
107
- ref = nodes .reference ("" , "" )
108
-
109
- ref ["refuri" ] = check_and_calc_base_url_rel_path (need_info ["external_url" ], fromdocname )
110
-
111
- ref ["classes" ].append (need_info ["external_css" ])
112
- ref .append (title )
113
- para += ref
114
- else :
115
- target_id = need_info ["target_id" ]
116
- ref = nodes .reference ("" , "" )
117
- ref ["refdocname" ] = need_info ["docname" ]
118
- ref ["refuri" ] = builder .get_relative_uri (fromdocname , need_info ["docname" ])
119
- ref ["refuri" ] += "#" + target_id
120
- ref .append (title )
121
- para += ref
122
- line_block .append (para )
123
- content .append (line_block )
86
+ if 0 < len (found_needs ):
87
+ line_block = nodes .line_block ()
88
+
89
+ # Add lineno to node
90
+ line_block .line = current_needfilter ["lineno" ]
91
+ for need_info in found_needs :
92
+ para = nodes .line ()
93
+ description = "{}: {}" .format (need_info ["id" ], need_info ["title" ])
94
+
95
+ if current_needfilter ["show_status" ] and need_info ["status" ]:
96
+ description += " (%s)" % need_info ["status" ]
97
+
98
+ if current_needfilter ["show_tags" ] and need_info ["tags" ]:
99
+ description += " [%s]" % "; " .join (need_info ["tags" ])
100
+
101
+ title = nodes .Text (description )
102
+
103
+ # Create a reference
104
+ if need_info ["hide" ]:
105
+ para += title
106
+ elif need_info ["is_external" ]:
107
+ assert need_info ["external_url" ] is not None , "External need without URL"
108
+ ref = nodes .reference ("" , "" )
109
+
110
+ ref ["refuri" ] = check_and_calc_base_url_rel_path (need_info ["external_url" ], fromdocname )
111
+
112
+ ref ["classes" ].append (need_info ["external_css" ])
113
+ ref .append (title )
114
+ para += ref
115
+ else :
116
+ target_id = need_info ["target_id" ]
117
+ ref = nodes .reference ("" , "" )
118
+ ref ["refdocname" ] = need_info ["docname" ]
119
+ ref ["refuri" ] = builder .get_relative_uri (fromdocname , need_info ["docname" ])
120
+ ref ["refuri" ] += "#" + target_id
121
+ ref .append (title )
122
+ para += ref
123
+ line_block .append (para )
124
+ content .append (line_block )
124
125
125
126
if len (content ) == 0 :
126
- content .append (no_needs_found_paragraph ())
127
-
127
+ content .append (no_needs_found_paragraph (current_needfilter .get ("filter_warning" )))
128
128
if current_needfilter ["show_filters" ]:
129
129
content .append (used_filter_paragraph (current_needfilter ))
130
130
0 commit comments