|
15 | 15 | -- of the license. -- |
16 | 16 | ------------------------------------------------------------------------------ |
17 | 17 |
|
| 18 | +with Ada.Containers.Ordered_Sets; |
| 19 | + |
18 | 20 | with VSS.Characters.Latin; |
19 | 21 | with VSS.Strings.Character_Iterators; |
20 | 22 | with VSS.Strings.Conversions; |
@@ -218,70 +220,192 @@ package body GNATdoc.Backend.RST is |
218 | 220 | Success); |
219 | 221 | File.New_Line (Success); |
220 | 222 |
|
221 | | - declare |
222 | | - Types : Entity_Information_Sets.Set; |
| 223 | + if Self.Alphabetical_Order then |
| 224 | + declare |
| 225 | + Types : Entity_Information_Sets.Set; |
223 | 226 |
|
224 | | - begin |
225 | | - Types.Union (Entity.Simple_Types); |
226 | | - Types.Union (Entity.Array_Types); |
227 | | - Types.Union (Entity.Record_Types); |
228 | | - Types.Union (Entity.Interface_Types); |
229 | | - Types.Union (Entity.Tagged_Types); |
230 | | - Types.Union (Entity.Task_Types); |
231 | | - Types.Union (Entity.Protected_Types); |
232 | | - Types.Union (Entity.Access_Types); |
233 | | - Types.Union (Entity.Subtypes); |
234 | | - |
235 | | - if not Types.Is_Empty then |
236 | | - File.Put ("-----", Success); |
237 | | - File.New_Line (Success); |
238 | | - File.Put ("Types", Success); |
239 | | - File.New_Line (Success); |
240 | | - File.Put ("-----", Success); |
241 | | - File.New_Line (Success); |
242 | | - File.New_Line (Success); |
243 | | - |
244 | | - for Item of Types loop |
245 | | - File.Put (".. ada:type:: type ", Success); |
246 | | - File.Put (Item.Name, Success); |
| 227 | + begin |
| 228 | + Types.Union (Entity.Simple_Types); |
| 229 | + Types.Union (Entity.Array_Types); |
| 230 | + Types.Union (Entity.Record_Types); |
| 231 | + Types.Union (Entity.Interface_Types); |
| 232 | + Types.Union (Entity.Tagged_Types); |
| 233 | + Types.Union (Entity.Task_Types); |
| 234 | + Types.Union (Entity.Protected_Types); |
| 235 | + Types.Union (Entity.Access_Types); |
| 236 | + Types.Union (Entity.Subtypes); |
| 237 | + |
| 238 | + if not Types.Is_Empty then |
| 239 | + File.Put ("-----", Success); |
247 | 240 | File.New_Line (Success); |
248 | | - File.Put (" :package: ", Success); |
249 | | - File.Put (Entity.Qualified_Name, Success); |
| 241 | + File.Put ("Types", Success); |
| 242 | + File.New_Line (Success); |
| 243 | + File.Put ("-----", Success); |
250 | 244 | File.New_Line (Success); |
251 | 245 | File.New_Line (Success); |
252 | 246 |
|
253 | | - File.Put_Lines |
254 | | - (GNATdoc.Comments.RST_Helpers.Get_RST_Documentation |
255 | | - (Indent => " ", |
256 | | - Documentation => Item.Documentation, |
257 | | - Pass_Through => Self.Pass_Through, |
258 | | - Code_Snippet => True), |
259 | | - Success); |
260 | | - |
261 | | - if Self.OOP_Mode |
262 | | - and then Item.Kind in Ada_Interface_Type | Ada_Tagged_Type |
263 | | - then |
264 | | - declare |
265 | | - Methods : GNATdoc.Entities.Entity_Reference_Sets.Set; |
266 | | - |
267 | | - begin |
268 | | - Methods.Union (Item.Dispatching_Declared); |
269 | | - Methods.Union (Item.Dispatching_Overrided); |
270 | | - Methods.Union (Item.Prefix_Callable_Declared); |
271 | | - |
272 | | - for Method of Methods loop |
273 | | - Generate_Subprogram_Documentation |
274 | | - (" ", |
275 | | - GNATdoc.Entities.To_Entity (Method.Signature).all, |
276 | | - Entity.Qualified_Name); |
277 | | - end loop; |
278 | | - end; |
| 247 | + for Item of Types loop |
| 248 | + File.Put (".. ada:type:: type ", Success); |
| 249 | + File.Put (Item.Name, Success); |
| 250 | + File.New_Line (Success); |
| 251 | + File.Put (" :package: ", Success); |
| 252 | + File.Put (Entity.Qualified_Name, Success); |
| 253 | + File.New_Line (Success); |
| 254 | + File.New_Line (Success); |
| 255 | + |
| 256 | + File.Put_Lines |
| 257 | + (GNATdoc.Comments.RST_Helpers.Get_RST_Documentation |
| 258 | + (Indent => " ", |
| 259 | + Documentation => Item.Documentation, |
| 260 | + Pass_Through => Self.Pass_Through, |
| 261 | + Code_Snippet => True), |
| 262 | + Success); |
| 263 | + |
| 264 | + if Self.OOP_Mode |
| 265 | + and then Item.Kind in Ada_Interface_Type | Ada_Tagged_Type |
| 266 | + then |
| 267 | + declare |
| 268 | + Methods : GNATdoc.Entities.Entity_Reference_Sets.Set; |
| 269 | + |
| 270 | + begin |
| 271 | + Methods.Union (Item.Dispatching_Declared); |
| 272 | + Methods.Union (Item.Dispatching_Overrided); |
| 273 | + Methods.Union (Item.Prefix_Callable_Declared); |
| 274 | + |
| 275 | + for Method of Methods loop |
| 276 | + Generate_Subprogram_Documentation |
| 277 | + (" ", |
| 278 | + GNATdoc.Entities.To_Entity |
| 279 | + (Method.Signature).all, |
| 280 | + Entity.Qualified_Name); |
| 281 | + end loop; |
| 282 | + end; |
| 283 | + end if; |
| 284 | + |
| 285 | + File.New_Line (Success); |
| 286 | + end loop; |
| 287 | + end if; |
| 288 | + end; |
| 289 | + |
| 290 | + else |
| 291 | + declare |
| 292 | + |
| 293 | + function Less |
| 294 | + (Left : not null GNATdoc.Entities.Entity_Information_Access; |
| 295 | + Right : not null GNATdoc.Entities.Entity_Information_Access) |
| 296 | + return Boolean; |
| 297 | + |
| 298 | + package Entity_Information_Sets is |
| 299 | + new Ada.Containers.Ordered_Sets |
| 300 | + (Element_Type => GNATdoc.Entities.Entity_Information_Access, |
| 301 | + "<" => Less, |
| 302 | + "=" => GNATdoc.Entities."="); |
| 303 | + |
| 304 | + procedure Union |
| 305 | + (Container : in out Entity_Information_Sets.Set; |
| 306 | + Items : GNATdoc.Entities.Entity_Information_Sets.Set); |
| 307 | + |
| 308 | + ---------- |
| 309 | + -- Less -- |
| 310 | + ---------- |
| 311 | + |
| 312 | + function Less |
| 313 | + (Left : not null GNATdoc.Entities.Entity_Information_Access; |
| 314 | + Right : not null GNATdoc.Entities.Entity_Information_Access) |
| 315 | + return Boolean |
| 316 | + is |
| 317 | + use type VSS.Strings.Character_Count; |
| 318 | + use type VSS.Strings.Line_Count; |
| 319 | + use type VSS.Strings.Virtual_String; |
| 320 | + |
| 321 | + begin |
| 322 | + if Left.Location.File < Right.Location.File then |
| 323 | + return True; |
| 324 | + |
| 325 | + elsif Left.Location.Line < Right.Location.Line then |
| 326 | + return True; |
| 327 | + |
| 328 | + elsif Left.Location.Column < Right.Location.Column then |
| 329 | + return True; |
| 330 | + |
| 331 | + else |
| 332 | + return False; |
279 | 333 | end if; |
| 334 | + end Less; |
| 335 | + |
| 336 | + ----------- |
| 337 | + -- Union -- |
| 338 | + ----------- |
| 339 | + |
| 340 | + procedure Union |
| 341 | + (Container : in out Entity_Information_Sets.Set; |
| 342 | + Items : GNATdoc.Entities.Entity_Information_Sets.Set) is |
| 343 | + begin |
| 344 | + for Item of Items loop |
| 345 | + Container.Insert (Item); |
| 346 | + end loop; |
| 347 | + end Union; |
| 348 | + |
| 349 | + Types : Entity_Information_Sets.Set; |
280 | 350 |
|
| 351 | + begin |
| 352 | + Union (Types, Entity.Simple_Types); |
| 353 | + Union (Types, Entity.Array_Types); |
| 354 | + Union (Types, Entity.Record_Types); |
| 355 | + Union (Types, Entity.Interface_Types); |
| 356 | + Union (Types, Entity.Tagged_Types); |
| 357 | + Union (Types, Entity.Task_Types); |
| 358 | + Union (Types, Entity.Protected_Types); |
| 359 | + Union (Types, Entity.Access_Types); |
| 360 | + Union (Types, Entity.Subtypes); |
| 361 | + |
| 362 | + if not Types.Is_Empty then |
| 363 | + File.Put ("-----", Success); |
281 | 364 | File.New_Line (Success); |
282 | | - end loop; |
283 | | - end if; |
284 | | - end; |
| 365 | + File.Put ("Types", Success); |
| 366 | + File.New_Line (Success); |
| 367 | + File.Put ("-----", Success); |
| 368 | + File.New_Line (Success); |
| 369 | + File.New_Line (Success); |
| 370 | + |
| 371 | + for Item of Types loop |
| 372 | + File.Put (".. ada:type:: type ", Success); |
| 373 | + File.Put (Item.Name, Success); |
| 374 | + File.New_Line (Success); |
| 375 | + File.Put (" :package: ", Success); |
| 376 | + File.Put (Entity.Qualified_Name, Success); |
| 377 | + File.New_Line (Success); |
| 378 | + File.New_Line (Success); |
| 379 | + |
| 380 | + File.Put_Lines |
| 381 | + (GNATdoc.Comments.RST_Helpers.Get_RST_Documentation |
| 382 | + (Indent => " ", |
| 383 | + Documentation => Item.Documentation, |
| 384 | + Pass_Through => Self.Pass_Through, |
| 385 | + Code_Snippet => True), |
| 386 | + Success); |
| 387 | + |
| 388 | + if Self.OOP_Mode |
| 389 | + and then Item.Kind in Ada_Interface_Type | Ada_Tagged_Type |
| 390 | + then |
| 391 | + for Method of Item.Belongs_Subprograms loop |
| 392 | + if not Is_Private_Entity |
| 393 | + (GNATdoc.Entities.To_Entity (Method.Signature)) |
| 394 | + then |
| 395 | + Generate_Subprogram_Documentation |
| 396 | + (" ", |
| 397 | + GNATdoc.Entities.To_Entity |
| 398 | + (Method.Signature).all, |
| 399 | + Entity.Qualified_Name); |
| 400 | + end if; |
| 401 | + end loop; |
| 402 | + end if; |
| 403 | + |
| 404 | + File.New_Line (Success); |
| 405 | + end loop; |
| 406 | + end if; |
| 407 | + end; |
| 408 | + end if; |
285 | 409 |
|
286 | 410 | begin |
287 | 411 | declare |
|
0 commit comments