matreshka_league_21.0.0_0c8f4d47/tools/documentation_generator/documentation_generator-driver.adb

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
with Ada.Characters.Conversions;
--with Ada.Command_Line;
--with Ada.Containers.Hashed_Maps;
--with Ada.Containers.Ordered_Sets;
--with Ada.Containers.Vectors;
--with Ada.Strings.Wide_Fixed;
--with Ada.Strings.Wide_Unbounded.Wide_Hash;
--with Ada.Unchecked_Conversion;
with Ada.Wide_Text_IO;
with Ada.Wide_Wide_Text_IO;

with Asis.Ada_Environments;
with Asis.Compilation_Units;
with Asis.Declarations;
with Asis.Elements;
--with Asis.Expressions;
with Asis.Implementation;

with League.Application;
with League.String_Vectors;
with League.Strings;

with Documentation_Generator.Database;
with Documentation_Generator.Wiki;

procedure Documentation_Generator.Driver is

   use Documentation_Generator.Database;

   Extractor_Context   : Asis.Context;
   Specification_Unit  : Asis.Compilation_Unit;
   Implementation_Unit : Asis.Compilation_Unit;
   Module              : Module_Access;

--   type Subprogram_Information is record
--      Declaration : Asis.Element;
--   end record;
--
--   type Subprogram_Information_Access is access all Subprogram_Information;
--
--   package Subprogram_Vectors is
--     new Ada.Containers.Vectors (Positive, Subprogram_Information_Access);
--
--   type Homograph_Information is record
--      Name        : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
--      Subprograms : Subprogram_Vectors.Vector;
--   end record;
--
--   type Homograph_Information_Access is access all Homograph_Information;
--
--   function Is_Less
--    (Left  : Homograph_Information_Access;
--     Right : Homograph_Information_Access) return Boolean;
--
--   package Homograph_Maps is
--     new Ada.Containers.Hashed_Maps
--          (Ada.Strings.Wide_Unbounded.Unbounded_Wide_String,
--           Homograph_Information_Access,
--           Ada.Strings.Wide_Unbounded.Wide_Hash,
--           Ada.Strings.Wide_Unbounded."=");
--
--   package Homograph_Sets is
--     new Ada.Containers.Ordered_Sets
--          (Homograph_Information_Access, Is_Less);
--
--   type Type_Information is record
--      Declaration : Asis.Element;
----      Name        : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
----      Is_Tagged   : Boolean;
--      Name_To_Operation : Homograph_Maps.Map;
--      Operations        : Homograph_Sets.Set;
--      Name_To_Related   : Homograph_Maps.Map;
--      Related           : Homograph_Sets.Set;
--   end record;
--
--   type Type_Information_Access is access all Type_Information;
--
--   function Hash (Item : Asis.Element) return Ada.Containers.Hash_Type;
--
--   package Type_Maps is
--     new Ada.Containers.Hashed_Maps
--          (Asis.Element,
--           Type_Information_Access,
--           Hash,
--           Asis.Elements.Is_Equal);
--
--   function Is_Less
--    (Left  : Type_Information_Access;
--     Right : Type_Information_Access) return Boolean;
--
--   package Type_Sets is
--     new Ada.Containers.Ordered_Sets
--          (Type_Information_Access, Is_Less);

   procedure Process_Specification;

   procedure Generate;

   procedure Dump (Element : Asis.Element);
   --  Output element's information suitable for debug purpose.

   procedure Analyze_Type_Declaration (Declaration : Asis.Element);
   --  Analyzes type declaration.

   procedure Analyze_Subprogram_Declaration (Declaration : Asis.Element);
   --  Analyzes subprogram declaration.

--   function Name_Of (Item : Type_Information) return Wide_String;
--
--   function "+"
--    (Item : Wide_String)
--       return Ada.Strings.Wide_Unbounded.Unbounded_Wide_String
--         renames Ada.Strings.Wide_Unbounded.To_Unbounded_Wide_String;
--   function "+"
--    (Item : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String)
--       return Wide_String renames Ada.Strings.Wide_Unbounded.To_Wide_String;
--
--   All_Types       : Type_Sets.Set;
--   Element_To_Type : Type_Maps.Map;

   ------------------------------------
   -- Analyze_Subprogram_Declaration --
   ------------------------------------

   procedure Analyze_Subprogram_Declaration (Declaration : Asis.Element) is
--
--         procedure Analyze_Parameter_Type_View
--          (View : Asis.Element; Type_Declaration : out Asis.Element);
--
--         ---------------------------------
--         -- Analyze_Parameter_Type_View --
--         ---------------------------------
--
--         procedure Analyze_Parameter_Type_View
--          (View : Asis.Element; Type_Declaration : out Asis.Element)
--         is
--            use type Asis.Attribute_Kinds;
--
--            Aux : Asis.Element := View;
--
--         begin
--            case Asis.Elements.Element_Kind (Aux) is
--               when Asis.A_Definition =>
--                  --  XXX Not implemented
--
--                  raise Program_Error;
--
--               when Asis.An_Expression =>
--                  --  For classwide parameters take prefix.
--
--                  if Asis.Elements.Attribute_Kind (Aux)
--                       = Asis.A_Class_Attribute
--                  then
--                     Aux := Asis.Expressions.Prefix (Aux);
--                  end if;
--
--                  Type_Declaration :=
--                    Asis.Expressions.Corresponding_Name_Declaration (Aux);
--
------                        Ada.Wide_Text_IO.Put_Line
------                         (Asis.Elements.Debug_Image (Parameter));
----
------                        case Asis.Elements.Expression_Kind (Parameter) is
------                           when Asis.An_Attribute_Reference =>
------                              case Asis.Elements.Attribute_Kind (Parameter) is
------                                 when Asis.A_Class_Attribute =>
------                                    --  XXX Not implemented
------
------                                    Parameter :=
------                                      Asis.Expressions.Prefix (Parameter);
------                                    null;
------                                    Ada.Wide_Text_IO.Put_Line
------                                     (Asis.Elements.Debug_Image (Parameter));
------
------                                 when others =>
------                                    Ada.Wide_Text_IO.Put_Line
------                                     (Asis.Elements.Debug_Image (Parameter));
------                              end case;
------
------                           when Asis.An_Identifier =>
------                              --  XXX Not implemented
------
------                              null;
------
------                           when others =>
------                              Ada.Wide_Text_IO.Put_Line
------                               (Asis.Elements.Debug_Image (Parameter));
------                        end case;
----
--               when others =>
--                  raise Program_Error;
--            end case;
--         end Analyze_Parameter_Type_View;
--
--         Name             : constant Wide_String
--           := Asis.Declarations.Defining_Name_Image
--               (Asis.Declarations.Names (Subprogram_Declaration) (1));
--         Parameters       : constant Asis.Parameter_Specification_List
--           := Asis.Declarations.Parameter_Profile (Subprogram_Declaration);
--         Type_Declaration : Asis.Element;
--         Class            : Type_Information_Access;
--         Homograph        : Homograph_Information_Access;
--
--      begin
--         --  Analyze first parameter to determine whether this subprogram
--         --  belongs to one of types declared in the package; and potentially
--         --  can be called using prefix notation.
--
--         Analyze_Parameter_Type_View
--          (Asis.Declarations.Object_Declaration_View (Parameters (1)),
--           Type_Declaration);
--
--         if Element_To_Type.Contains (Type_Declaration) then
--            Class := Element_To_Type.Element (Type_Declaration);
--
--            if not Class.Name_To_Operation.Contains (+Name) then
--               Homograph :=
--                 new Homograph_Information'
--                      (Name        => +Name,
--                       Subprograms => Subprogram_Vectors.Empty_Vector);
--               Class.Operations.Insert (Homograph);
--               Class.Name_To_Operation.Insert (+Name, Homograph);
--
--            else
--               Homograph := Class.Name_To_Operation.Element (+Name);
--            end if;
--
--            Homograph.Subprograms.Append
--             (new Subprogram_Information'
--                   (Declaration => Subprogram_Declaration));
--
--            return;
--         end if;
--
--         --  Check whether specified subprogram is a function to implement
--         --  operator and add it to the list of operations when second
--         --  parameter has type declared in the package.
--
--         if Asis.Elements.Declaration_Kind (Subprogram_Declaration)
--              = Asis.A_Function_Declaration
--           and (Name = """=""" or Name = """&""")
--         then
--            Analyze_Parameter_Type_View
--             (Asis.Declarations.Object_Declaration_View (Parameters (2)),
--              Type_Declaration);
--
--            if Element_To_Type.Contains (Type_Declaration) then
--               Class := Element_To_Type.Element (Type_Declaration);
--
--               if not Class.Name_To_Operation.Contains (+Name) then
--                  Homograph :=
--                    new Homograph_Information'
--                         (Name        => +Name,
--                          Subprograms => Subprogram_Vectors.Empty_Vector);
--                  Class.Operations.Insert (Homograph);
--                  Class.Name_To_Operation.Insert (+Name, Homograph);
--
--               else
--                  Homograph := Class.Name_To_Operation.Element (+Name);
--               end if;
--
--               Homograph.Subprograms.Append
--                (new Subprogram_Information'
--                      (Declaration => Subprogram_Declaration));
--
--               return;
--            end if;
--         end if;
--
--         --  Analyze type of return value for the function to list subprogram
--         --  as related.
--
--         if Asis.Elements.Declaration_Kind (Subprogram_Declaration)
--              = Asis.A_Function_Declaration
--         then
--            Analyze_Parameter_Type_View
--             (Asis.Declarations.Result_Profile (Subprogram_Declaration),
--              Type_Declaration);
--
--            if Element_To_Type.Contains (Type_Declaration) then
--               Class := Element_To_Type.Element (Type_Declaration);
--
--               if not Class.Name_To_Related.Contains (+Name) then
--                  Homograph :=
--                    new Homograph_Information'
--                         (Name        => +Name,
--                          Subprograms => Subprogram_Vectors.Empty_Vector);
--                  Class.Related.Insert (Homograph);
--                  Class.Name_To_Related.Insert (+Name, Homograph);
--
--               else
--                  Homograph := Class.Name_To_Related.Element (+Name);
--               end if;
--
--               Homograph.Subprograms.Append
--                (new Subprogram_Information'
--                      (Declaration => Subprogram_Declaration));
--
--               return;
--            end if;
--         end if;
--
--         Ada.Wide_Text_IO.Put_Line (Name);
   begin
      null;
   end Analyze_Subprogram_Declaration;

   ------------------------------
   -- Analyze_Type_Declaration --
   ------------------------------

   procedure Analyze_Type_Declaration (Declaration : Asis.Element) is
      Type_Declaration : constant Type_Access := Lookup (Declaration);

   begin
      null;
   end Analyze_Type_Declaration;

   ----------
   -- Dump --
   ----------

   procedure Dump (Element : Asis.Element) is
   begin
      Ada.Wide_Text_IO.Put_Line
       ("--------------------------------------------------------------------"
          & "----------");
      Ada.Wide_Text_IO.Put_Line
       ("Element Kind     : "
          & Asis.Element_Kinds'Wide_Image
             (Asis.Elements.Element_Kind (Element)));

      case Asis.Elements.Element_Kind (Element) is
         when Asis.A_Declaration =>
            Ada.Wide_Text_IO.Put_Line
             ("Declaration Kind : "
                & Asis.Declaration_Kinds'Wide_Image
                   (Asis.Elements.Declaration_Kind (Element)));

         when others =>
            null;
      end case;

      Ada.Wide_Text_IO.Put_Line (Asis.Elements.Debug_Image (Element));
   end Dump;

   --------------
   -- Generate --
   --------------

   procedure Generate is
--
--      procedure Put (Position : Type_Sets.Cursor);
--
--      procedure Dump_Subprograms (Position : Type_Sets.Cursor);
--
--      ----------------------
--      -- Dump_Subprograms --
--      ----------------------
--
--      procedure Dump_Subprograms (Position : Type_Sets.Cursor) is
--
--         procedure Dump_Homograph (Position : Homograph_Sets.Cursor);
--
--         --------------------
--         -- Dump_Homograph --
--         --------------------
--
--         procedure Dump_Homograph (Position : Homograph_Sets.Cursor) is
--            Homograph : constant Homograph_Information_Access
--              := Homograph_Sets.Element (Position);
--
--         begin
--            Ada.Wide_Text_IO.Put_Line ("  " & (+Homograph.Name));
----            Ada.Strings.Wide_Unbounded.Wide_Text_IO.Put_Line (Homograph.Name
--         end Dump_Homograph;
--
--         Info    : constant Type_Information_Access
--           := Type_Sets.Element (Position);
--         Section : constant Wide_String
--           := "Subprograms of " & Name_Of (Info.all);
--
--      begin
--         Ada.Wide_Text_IO.Put_Line (Section);
--         Ada.Wide_Text_IO.Put_Line
--          (Ada.Strings.Wide_Fixed."*" (Section'Length, '-'));
--
--         if not Info.Operations.Is_Empty then
--            Ada.Wide_Text_IO.New_Line;
--            Ada.Wide_Text_IO.Put_Line ("============");
--            Ada.Wide_Text_IO.Put_Line (" Operations");
--            Ada.Wide_Text_IO.Put_Line ("============");
--            Info.Operations.Iterate (Dump_Homograph'Access);
--         end if;
--
--         if not Info.Related.Is_Empty then
--            Ada.Wide_Text_IO.New_Line;
--            Ada.Wide_Text_IO.Put_Line ("====================");
--            Ada.Wide_Text_IO.Put_Line (" Related Operations");
--            Ada.Wide_Text_IO.Put_Line ("====================");
--            Info.Related.Iterate (Dump_Homograph'Access);
--         end if;
--      end Dump_Subprograms;
--
--      ---------
--      -- Put --
--      ---------
--
--      procedure Put (Position : Type_Sets.Cursor) is
--         Info : Type_Information_Access := Type_Sets.Element (Position);
--
--      begin
--         Ada.Wide_Text_IO.Put_Line ("  " & Name_Of (Info.all));
--      end Put;

      procedure Output_Type (The_Type : not null Type_Access) is
      begin
         Ada.Wide_Wide_Text_IO.Put_Line (The_Type.Name.To_Wide_Wide_String);
      end Output_Type;

   begin
      Ada.Wide_Wide_Text_IO.Put_Line ("List of Types");
      Ada.Wide_Wide_Text_IO.Put_Line ("-------------");
      Iterate (Output_Type'Access);

--      All_Types.Iterate (Dump_Subprograms'Access);
      null;
   end Generate;

--   ----------
--   -- Hash --
--   ----------
--
--   function Hash (Item : Asis.Element) return Ada.Containers.Hash_Type is
--      function To_Hash_Type is
--        new Ada.Unchecked_Conversion
--             (Asis.Asis_Integer, Ada.Containers.Hash_Type);
--
--   begin
--      return To_Hash_Type (Asis.Elements.Hash (Item));
--   end Hash;
--
--   -------------
--   -- Is_Less --
--   -------------
--
--   function Is_Less
--    (Left  : Homograph_Information_Access;
--     Right : Homograph_Information_Access) return Boolean
--   is
--      use type Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
--
--   begin
--      return Left.Name < Right.Name;
--   end Is_Less;
--
--   -------------
--   -- Is_Less --
--   -------------
--
--   function Is_Less
--    (Left  : Type_Information_Access;
--     Right : Type_Information_Access) return Boolean
--   is
--      L : constant Wide_String
--        := Asis.Compilation_Units.Unit_Full_Name
--            (Asis.Elements.Enclosing_Compilation_Unit (Left.Declaration))
--             & '.'
--             & Name_Of (Left.all);
--      R : constant Wide_String
--        := Asis.Compilation_Units.Unit_Full_Name
--            (Asis.Elements.Enclosing_Compilation_Unit (Right.Declaration))
--             & '.'
--             & Name_Of (Right.all);
--
--   begin
--      return L < R;
--   end Is_Less;
--
--   -------------
--   -- Name_Of --
--   -------------
--
--   function Name_Of (Item : Type_Information) return Wide_String is
--      Name : constant Asis.Defining_Name
--        := Asis.Declarations.Names (Item.Declaration) (1);
--
--   begin
--      return Asis.Declarations.Defining_Name_Image (Name);
--   end Name_Of;

   ---------------------------
   -- Process_Specification --
   ---------------------------

   procedure Process_Specification is

--      use type Asis.Declaration_Kinds;
--
--      procedure Process_Type (Type_Declaration : Asis.Element);
--      --  Process type declaration.
--
--      procedure Process_Subprogram (Subprogram_Declaration : Asis.Element);
--      --  Process declaration of the subprogram and add it to corresponding
--      --  set of subprograms.
--
--      ------------------------
--      -- Process_Subprogram --
--      ------------------------
--
--      procedure Process_Subprogram (Subprogram_Declaration : Asis.Element) is
--
--         procedure Analyze_Parameter_Type_View
--          (View : Asis.Element; Type_Declaration : out Asis.Element);
--
--         ---------------------------------
--         -- Analyze_Parameter_Type_View --
--         ---------------------------------
--
--         procedure Analyze_Parameter_Type_View
--          (View : Asis.Element; Type_Declaration : out Asis.Element)
--         is
--            use type Asis.Attribute_Kinds;
--
--            Aux : Asis.Element := View;
--
--         begin
--            case Asis.Elements.Element_Kind (Aux) is
--               when Asis.A_Definition =>
--                  --  XXX Not implemented
--
--                  raise Program_Error;
--
--               when Asis.An_Expression =>
--                  --  For classwide parameters take prefix.
--
--                  if Asis.Elements.Attribute_Kind (Aux)
--                       = Asis.A_Class_Attribute
--                  then
--                     Aux := Asis.Expressions.Prefix (Aux);
--                  end if;
--
--                  Type_Declaration :=
--                    Asis.Expressions.Corresponding_Name_Declaration (Aux);
--
------                        Ada.Wide_Text_IO.Put_Line
------                         (Asis.Elements.Debug_Image (Parameter));
----
------                        case Asis.Elements.Expression_Kind (Parameter) is
------                           when Asis.An_Attribute_Reference =>
------                              case Asis.Elements.Attribute_Kind (Parameter) is
------                                 when Asis.A_Class_Attribute =>
------                                    --  XXX Not implemented
------
------                                    Parameter :=
------                                      Asis.Expressions.Prefix (Parameter);
------                                    null;
------                                    Ada.Wide_Text_IO.Put_Line
------                                     (Asis.Elements.Debug_Image (Parameter));
------
------                                 when others =>
------                                    Ada.Wide_Text_IO.Put_Line
------                                     (Asis.Elements.Debug_Image (Parameter));
------                              end case;
------
------                           when Asis.An_Identifier =>
------                              --  XXX Not implemented
------
------                              null;
------
------                           when others =>
------                              Ada.Wide_Text_IO.Put_Line
------                               (Asis.Elements.Debug_Image (Parameter));
------                        end case;
----
--               when others =>
--                  raise Program_Error;
--            end case;
--         end Analyze_Parameter_Type_View;
--
--         Name             : constant Wide_String
--           := Asis.Declarations.Defining_Name_Image
--               (Asis.Declarations.Names (Subprogram_Declaration) (1));
--         Parameters       : constant Asis.Parameter_Specification_List
--           := Asis.Declarations.Parameter_Profile (Subprogram_Declaration);
--         Type_Declaration : Asis.Element;
--         Class            : Type_Information_Access;
--         Homograph        : Homograph_Information_Access;
--
--      begin
--         --  Analyze first parameter to determine whether this subprogram
--         --  belongs to one of types declared in the package; and potentially
--         --  can be called using prefix notation.
--
--         Analyze_Parameter_Type_View
--          (Asis.Declarations.Object_Declaration_View (Parameters (1)),
--           Type_Declaration);
--
--         if Element_To_Type.Contains (Type_Declaration) then
--            Class := Element_To_Type.Element (Type_Declaration);
--
--            if not Class.Name_To_Operation.Contains (+Name) then
--               Homograph :=
--                 new Homograph_Information'
--                      (Name        => +Name,
--                       Subprograms => Subprogram_Vectors.Empty_Vector);
--               Class.Operations.Insert (Homograph);
--               Class.Name_To_Operation.Insert (+Name, Homograph);
--
--            else
--               Homograph := Class.Name_To_Operation.Element (+Name);
--            end if;
--
--            Homograph.Subprograms.Append
--             (new Subprogram_Information'
--                   (Declaration => Subprogram_Declaration));
--
--            return;
--         end if;
--
--         --  Check whether specified subprogram is a function to implement
--         --  operator and add it to the list of operations when second
--         --  parameter has type declared in the package.
--
--         if Asis.Elements.Declaration_Kind (Subprogram_Declaration)
--              = Asis.A_Function_Declaration
--           and (Name = """=""" or Name = """&""")
--         then
--            Analyze_Parameter_Type_View
--             (Asis.Declarations.Object_Declaration_View (Parameters (2)),
--              Type_Declaration);
--
--            if Element_To_Type.Contains (Type_Declaration) then
--               Class := Element_To_Type.Element (Type_Declaration);
--
--               if not Class.Name_To_Operation.Contains (+Name) then
--                  Homograph :=
--                    new Homograph_Information'
--                         (Name        => +Name,
--                          Subprograms => Subprogram_Vectors.Empty_Vector);
--                  Class.Operations.Insert (Homograph);
--                  Class.Name_To_Operation.Insert (+Name, Homograph);
--
--               else
--                  Homograph := Class.Name_To_Operation.Element (+Name);
--               end if;
--
--               Homograph.Subprograms.Append
--                (new Subprogram_Information'
--                      (Declaration => Subprogram_Declaration));
--
--               return;
--            end if;
--         end if;
--
--         --  Analyze type of return value for the function to list subprogram
--         --  as related.
--
--         if Asis.Elements.Declaration_Kind (Subprogram_Declaration)
--              = Asis.A_Function_Declaration
--         then
--            Analyze_Parameter_Type_View
--             (Asis.Declarations.Result_Profile (Subprogram_Declaration),
--              Type_Declaration);
--
--            if Element_To_Type.Contains (Type_Declaration) then
--               Class := Element_To_Type.Element (Type_Declaration);
--
--               if not Class.Name_To_Related.Contains (+Name) then
--                  Homograph :=
--                    new Homograph_Information'
--                         (Name        => +Name,
--                          Subprograms => Subprogram_Vectors.Empty_Vector);
--                  Class.Related.Insert (Homograph);
--                  Class.Name_To_Related.Insert (+Name, Homograph);
--
--               else
--                  Homograph := Class.Name_To_Related.Element (+Name);
--               end if;
--
--               Homograph.Subprograms.Append
--                (new Subprogram_Information'
--                      (Declaration => Subprogram_Declaration));
--
--               return;
--            end if;
--         end if;
--
--         Ada.Wide_Text_IO.Put_Line (Name);
--      end Process_Subprogram;
--
--      ------------------
--      -- Process_Type --
--      ------------------
--
--      procedure Process_Type (Type_Declaration : Asis.Element) is
--         Info : Type_Information_Access;
--
--      begin
--         Info :=
--           new Type_Information'
--                (Type_Declaration,
----                 Asis.Elements.Declaration_Kind (Type_Declaration)
----                   = Asis.A_Private_Type_Declaration
----                   and then Asis.Elements.Definition_Kind
----                             (Asis.Declarations.Type_Declaration_View
----                               (Type_Declaration))
----                     = Asis.A_Tagged_Private_Type_Definition,
--                 Homograph_Maps.Empty_Map,
--                 Homograph_Sets.Empty_Set,
--                 Homograph_Maps.Empty_Map,
--                 Homograph_Sets.Empty_Set);
--         All_Types.Insert (Info);
--         Element_To_Type.Insert (Type_Declaration, Info);
--      end Process_Type;

      Decls : constant Asis.Declarative_Item_List
        := Asis.Declarations.Visible_Part_Declarative_Items
            (Asis.Elements.Unit_Declaration (Specification_Unit));
      Unit  : constant Compilation_Unit_Access
        := Create (Specification_Unit, Module);

   begin
      for J in Decls'Range loop
         declare
            use type Asis.Element_Kinds;

            Element : constant Asis.Element := Decls (J);

         begin
            if Asis.Elements.Element_Kind (Element) /= Asis.A_Declaration then
               raise Program_Error;
            end if;

            case Asis.Elements.Declaration_Kind (Element) is
               when Asis.An_Ordinary_Type_Declaration =>
                  Analyze_Type_Declaration (Element);

               when Asis.A_Private_Type_Declaration =>
                  Analyze_Type_Declaration (Element);

               when Asis.A_Deferred_Constant_Declaration =>
                  null;

               when Asis.A_Procedure_Declaration =>
                  Analyze_Subprogram_Declaration (Element);

               when Asis.A_Function_Declaration =>
                  Analyze_Subprogram_Declaration (Element);

               when others =>
                  Dump (Element);

                  raise Program_Error;
            end case;
         end;
      end loop;
   end Process_Specification;

   Arguments : constant League.String_Vectors.Universal_String_Vector
     := League.Application.Arguments;
   Files     : League.Strings.Universal_String;
   Units     : League.String_Vectors.Universal_String_Vector;
   Index     : Positive := 1;

begin
   --  Process command line arguments.

   while Index < Arguments.Length loop
      Files.Append (' ');
      Files.Append (Arguments.Element (Index));
      Units.Append (Arguments.Element (Index + 1));
      Index := Index + 2;
   end loop;

   Asis.Implementation.Initialize ("-asis12");
   Asis.Ada_Environments.Associate
    (Extractor_Context,
     "Documentation_Extractor_Context",
     "-CN " & Files.To_UTF_16_Wide_String);
   Asis.Ada_Environments.Open (Extractor_Context);

   Module :=
     Create
      (League.Strings.To_Universal_String ("League"),
       League.Strings.To_Universal_String ("Core components"));

   for J in 1 .. Units.Length loop
      Specification_Unit :=
        Asis.Compilation_Units.Library_Unit_Declaration
         (Units.Element (J).To_UTF_16_Wide_String,
          Extractor_Context);
--      Implementation_Unit :=
--        Asis.Compilation_Units.Compilation_Unit_Body
--         (Units.Element (J).To_UTF_16_Wide_String,
--          Extractor_Context);

      Process_Specification;
   end loop;

   Generate;
   Wiki.Generate;

   Asis.Ada_Environments.Close (Extractor_Context);
   Asis.Ada_Environments.Dissociate (Extractor_Context);
   Asis.Implementation.Finalize;
end Documentation_Generator.Driver;