Compare commits
No commits in common. "1a75f9620fb04a8417e23aaf7946f91b96a83558" and "72c71e2a7015867a2aec56802c3323a18fddd931" have entirely different histories.
1a75f9620f
...
72c71e2a70
3
fetch.sh
3
fetch.sh
|
|
@ -58,7 +58,6 @@ cat > /tmp/front_matter <<-EOF
|
||||||
---
|
---
|
||||||
title: Ada Quality and Style Guide
|
title: Ada Quality and Style Guide
|
||||||
description: Guidelines for Professional Programmers
|
description: Guidelines for Professional Programmers
|
||||||
sidebar_position: 0
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> **_Guidelines for Professional Programmers_**
|
> **_Guidelines for Professional Programmers_**
|
||||||
|
|
@ -71,4 +70,4 @@ sed -e '/<noinclude>/,/<.noinclude>/d' data/Ada_Style_Guide.wiki |
|
||||||
cat /tmp/front_matter /tmp/mdx note.mdx > $OUTPUT/Ada_Style_Guide.mdx
|
cat /tmp/front_matter /tmp/mdx note.mdx > $OUTPUT/Ada_Style_Guide.mdx
|
||||||
|
|
||||||
echo From ada-lang-io repo-folder run:
|
echo From ada-lang-io repo-folder run:
|
||||||
echo yarn prettier --write $OUTPUT
|
echo yarn prettier --write $OUTPUT
|
||||||
|
|
@ -7,12 +7,9 @@ with League.JSON.Objects;
|
||||||
with League.JSON.Values;
|
with League.JSON.Values;
|
||||||
with League.Strings;
|
with League.Strings;
|
||||||
|
|
||||||
with Pandoc;
|
|
||||||
|
|
||||||
procedure Aqs2mdx is
|
procedure Aqs2mdx is
|
||||||
use type League.Strings.Universal_String;
|
use type League.Strings.Universal_String;
|
||||||
use type League.Holders.Universal_Integer;
|
use type League.Holders.Universal_Integer;
|
||||||
use all type Pandoc.Object_Type;
|
|
||||||
|
|
||||||
function "+" (T : Wide_Wide_String) return League.Strings.Universal_String
|
function "+" (T : Wide_Wide_String) return League.Strings.Universal_String
|
||||||
renames League.Strings.To_Universal_String;
|
renames League.Strings.To_Universal_String;
|
||||||
|
|
@ -96,115 +93,97 @@ procedure Aqs2mdx is
|
||||||
return League.JSON.Arrays.JSON_Array
|
return League.JSON.Arrays.JSON_Array
|
||||||
is
|
is
|
||||||
List : League.JSON.Arrays.JSON_Array;
|
List : League.JSON.Arrays.JSON_Array;
|
||||||
Pandoc_Type : constant Pandoc.Object_Type := Pandoc.Get_Type (Block);
|
|
||||||
begin
|
begin
|
||||||
case Pandoc_Type is
|
if Block (+"t").To_String.To_Wide_Wide_String = "Table" then
|
||||||
when Block_Table =>
|
-- Flatting tables because no multiline tables in .md
|
||||||
-- Flatten tables since there are no native multiline tables
|
|
||||||
-- in .md
|
|
||||||
declare
|
|
||||||
-- Table structure in pandoc-types-1.23.1. See
|
|
||||||
-- https://hackage.haskell.org/package/pandoc-types-1.23.1/
|
|
||||||
-- docs/
|
|
||||||
-- Text-Pandoc-Definition.html
|
|
||||||
--
|
|
||||||
-- Table:
|
|
||||||
-- Attr Caption [ColSpec] TableHead [TableBody] TableFoot
|
|
||||||
-- 1 2 3 4 5 6
|
|
||||||
|
|
||||||
Content : constant League.JSON.Arrays.JSON_Array :=
|
declare
|
||||||
Block (Pandoc.Content_String).To_Array;
|
-- Table structure in pandoc-types-1.23.1. See
|
||||||
|
-- https://hackage.haskell.org/package/pandoc-types-1.23.1/docs/
|
||||||
|
-- Text-Pandoc-Definition.html
|
||||||
|
--
|
||||||
|
-- Table:
|
||||||
|
-- Attr Caption [ColSpec] TableHead [TableBody] TableFoot
|
||||||
|
-- 1 2 3 4 5 6
|
||||||
|
|
||||||
Table_Body_List : constant League.JSON.Arrays.JSON_Array :=
|
Content : constant League.JSON.Arrays.JSON_Array :=
|
||||||
Content (5).To_Array;
|
Block (+"c").To_Array;
|
||||||
|
|
||||||
-- A body of a table, with an intermediate head, intermediate
|
Table_Body_List : constant League.JSON.Arrays.JSON_Array :=
|
||||||
-- body, and the specified number of row header columns in the
|
Content (5).To_Array;
|
||||||
-- intermediate body.
|
-- A body of a table, with an intermediate head, intermediate
|
||||||
--
|
-- body, and the specified number of row header columns in the
|
||||||
-- TableBody Attr RowHeadColumns [Row] [Row]
|
-- intermediate body.
|
||||||
-- 1 2 3 4
|
--
|
||||||
Table_Body : constant League.JSON.Arrays.JSON_Array :=
|
-- TableBody Attr RowHeadColumns [Row] [Row]
|
||||||
Table_Body_List (1).To_Array;
|
-- 1 2 3 4
|
||||||
|
|
||||||
Row_List : constant League.JSON.Arrays.JSON_Array :=
|
Table_Body : constant League.JSON.Arrays.JSON_Array :=
|
||||||
Table_Body (4).To_Array;
|
Table_Body_List (1).To_Array;
|
||||||
|
|
||||||
-- A table row.
|
Row_List : constant League.JSON.Arrays.JSON_Array :=
|
||||||
-- Row Attr [Cell]
|
Table_Body (4).To_Array;
|
||||||
-- 1 2
|
|
||||||
Row : constant League.JSON.Arrays.JSON_Array :=
|
|
||||||
Row_List (1).To_Array;
|
|
||||||
|
|
||||||
Cell_List : constant League.JSON.Arrays.JSON_Array :=
|
Row : constant League.JSON.Arrays.JSON_Array :=
|
||||||
Row (2).To_Array;
|
Row_List (1).To_Array;
|
||||||
|
-- A table row.
|
||||||
|
-- Row Attr [Cell]
|
||||||
|
-- 1 2
|
||||||
|
|
||||||
Columns_Div : Pandoc.Content_Arr (1 .. Cell_List.Length);
|
Cell_List : constant League.JSON.Arrays.JSON_Array :=
|
||||||
|
Row (2).To_Array;
|
||||||
|
|
||||||
Outer_Attr : constant League.JSON.Values.JSON_Value :=
|
begin
|
||||||
Pandoc.Attr (+"className", +"multi-column");
|
pragma Assert (Content.Length = 6);
|
||||||
|
pragma Assert (Table_Body_List.Length = 1);
|
||||||
|
pragma Assert (Row_List.Length = 1);
|
||||||
|
pragma Assert (Cell_List.Length <= 3);
|
||||||
|
|
||||||
Inner_Attr : constant League.JSON.Values.JSON_Value :=
|
for J in 1 .. Cell_List.Length loop
|
||||||
Pandoc.Attr (+"className", +"multi-column-child");
|
|
||||||
|
|
||||||
begin
|
|
||||||
pragma Assert (Content.Length = 6);
|
|
||||||
pragma Assert (Table_Body_List.Length = 1);
|
|
||||||
pragma Assert (Row_List.Length = 1);
|
|
||||||
pragma Assert (Cell_List.Length <= 3);
|
|
||||||
|
|
||||||
for J in 1 .. Cell_List.Length loop
|
|
||||||
declare
|
|
||||||
-- A table cell.
|
|
||||||
-- Cell Attr Alignment RowSpan ColSpan [Block]
|
|
||||||
-- 1 2 3 4 5
|
|
||||||
Cell : constant League.JSON.Arrays.JSON_Array :=
|
|
||||||
Cell_List (J).To_Array;
|
|
||||||
|
|
||||||
Block_List : constant League.JSON.Values.JSON_Value :=
|
|
||||||
Cell (5);
|
|
||||||
|
|
||||||
begin
|
|
||||||
pragma Assert (Cell.Length = 5);
|
|
||||||
|
|
||||||
Columns_Div (J) := Pandoc.Div (Inner_Attr, Block_List);
|
|
||||||
end;
|
|
||||||
end loop;
|
|
||||||
|
|
||||||
List.Append (Pandoc.Div (Outer_Attr, Columns_Div));
|
|
||||||
end;
|
|
||||||
when Block_Header =>
|
|
||||||
if Block (Pandoc.Content_String).To_Array.Element (1)
|
|
||||||
.To_Integer = 2
|
|
||||||
and then Block (Pandoc.Content_String).To_Array.Element (2)
|
|
||||||
.To_Array.Element (1).To_String = +"introduction"
|
|
||||||
-- This relies on the fact that Pandoc converts a title
|
|
||||||
-- From mediawiki and adds a lower-case id to the header
|
|
||||||
then
|
|
||||||
-- Drop toplevel 'Introduction' section header
|
|
||||||
null;
|
|
||||||
else
|
|
||||||
List.Append (Block.To_JSON_Value);
|
|
||||||
end if;
|
|
||||||
when Inline_Link =>
|
|
||||||
List.Append (Traverse_Link (Block));
|
|
||||||
when others =>
|
|
||||||
if Block (Pandoc.Content_String).To_Array.Length > 0 then
|
|
||||||
declare
|
declare
|
||||||
-- Traverse nested blocks
|
Cell : constant League.JSON.Arrays.JSON_Array :=
|
||||||
Copy : League.JSON.Objects.JSON_Object := Block;
|
Cell_List (J).To_Array;
|
||||||
Arr : constant League.JSON.Arrays.JSON_Array :=
|
-- A table cell.
|
||||||
Block (Pandoc.Content_String).To_Array;
|
-- Cell Attr Alignment RowSpan ColSpan [Block]
|
||||||
|
-- 1 2 3 4 5
|
||||||
|
|
||||||
|
Block_List : constant League.JSON.Arrays.JSON_Array :=
|
||||||
|
Cell (5).To_Array;
|
||||||
begin
|
begin
|
||||||
Copy.Insert (
|
pragma Assert (Cell.Length = 5);
|
||||||
Pandoc.Content_String,
|
|
||||||
Traverse_List (Arr).To_JSON_Value);
|
for K in 1 .. Block_List.Length loop
|
||||||
List.Append (Copy.To_JSON_Value);
|
List.Append (Block_List (K));
|
||||||
|
end loop;
|
||||||
end;
|
end;
|
||||||
else
|
end loop;
|
||||||
List.Append (Block.To_JSON_Value);
|
end;
|
||||||
end if;
|
|
||||||
end case;
|
elsif Block (+"t").To_String.To_Wide_Wide_String = "Header"
|
||||||
|
and then Block (+"c").To_Array.Element (1).To_Integer = 2
|
||||||
|
and then Block (+"c").To_Array.Element (2)
|
||||||
|
.To_Array.Element (1).To_String = +"introduction"
|
||||||
|
then
|
||||||
|
-- Drop toppest 'Introduction' section header
|
||||||
|
null;
|
||||||
|
|
||||||
|
elsif Block (+"t").To_String.To_Wide_Wide_String = "Link" then
|
||||||
|
List.Append (Traverse_Link (Block));
|
||||||
|
|
||||||
|
elsif Block (+"c").To_Array.Length > 0 then
|
||||||
|
declare
|
||||||
|
-- Traverse nested blocks
|
||||||
|
Copy : League.JSON.Objects.JSON_Object := Block;
|
||||||
|
begin
|
||||||
|
Copy.Insert
|
||||||
|
(+"c", Traverse_List (Block (+"c").To_Array).To_JSON_Value);
|
||||||
|
|
||||||
|
List.Append (Copy.To_JSON_Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
else -- Something else (if any?)
|
||||||
|
List.Append (Block.To_JSON_Value);
|
||||||
|
end if;
|
||||||
|
|
||||||
return List;
|
return List;
|
||||||
end Traverse_Block;
|
end Traverse_Block;
|
||||||
|
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
pragma Ada_2022;
|
|
||||||
|
|
||||||
with League.JSON.Arrays;
|
|
||||||
|
|
||||||
package body Pandoc is
|
|
||||||
|
|
||||||
function Attr
|
|
||||||
(Key : League.Strings.Universal_String;
|
|
||||||
Value : League.Strings.Universal_String;
|
|
||||||
Id : League.Strings.Universal_String :=
|
|
||||||
League.Strings.Empty_Universal_String)
|
|
||||||
return League.JSON.Values.JSON_Value is
|
|
||||||
(Attr (Id, [Key], [Value]));
|
|
||||||
|
|
||||||
function Attr
|
|
||||||
(Id : League.Strings.Universal_String;
|
|
||||||
Key : String_Array;
|
|
||||||
Value : String_Array) return League.JSON.Values.JSON_Value
|
|
||||||
is
|
|
||||||
Outer : League.JSON.Arrays.JSON_Array;
|
|
||||||
Other : League.JSON.Arrays.JSON_Array;
|
|
||||||
Inner : League.JSON.Arrays.JSON_Array;
|
|
||||||
begin
|
|
||||||
Outer.Append (League.JSON.Values.To_JSON_Value (Id));
|
|
||||||
Outer.Append (Other.To_JSON_Value);
|
|
||||||
|
|
||||||
for K in Key'Range loop
|
|
||||||
declare
|
|
||||||
Pair : League.JSON.Arrays.JSON_Array;
|
|
||||||
begin
|
|
||||||
Pair.Append (League.JSON.Values.To_JSON_Value (Key (K)));
|
|
||||||
Pair.Append (League.JSON.Values.To_JSON_Value (Value (K)));
|
|
||||||
Inner.Append (Pair.To_JSON_Value);
|
|
||||||
end;
|
|
||||||
end loop;
|
|
||||||
|
|
||||||
Outer.Append (Inner.To_JSON_Value);
|
|
||||||
|
|
||||||
return Outer.To_JSON_Value;
|
|
||||||
end Attr;
|
|
||||||
|
|
||||||
function Div (
|
|
||||||
Attr : League.JSON.Values.JSON_Value;
|
|
||||||
Content : Content_Arr) return League.JSON.Values.JSON_Value
|
|
||||||
is
|
|
||||||
Block : League.JSON.Objects.JSON_Object;
|
|
||||||
Out_Content : League.JSON.Arrays.JSON_Array;
|
|
||||||
Content_Block : League.JSON.Arrays.JSON_Array;
|
|
||||||
begin
|
|
||||||
Block.Insert (
|
|
||||||
Type_String,
|
|
||||||
League.JSON.Values.To_JSON_Value (
|
|
||||||
Obj_String_Representation (Block_Div)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
for C in Content'Range loop
|
|
||||||
Content_Block.Append (Content (C));
|
|
||||||
end loop;
|
|
||||||
|
|
||||||
Out_Content.Append (Attr);
|
|
||||||
Out_Content.Append (Content_Block.To_JSON_Value);
|
|
||||||
|
|
||||||
Block.Insert (
|
|
||||||
Content_String,
|
|
||||||
Out_Content.To_JSON_Value
|
|
||||||
);
|
|
||||||
|
|
||||||
return Block.To_JSON_Value;
|
|
||||||
end Div;
|
|
||||||
|
|
||||||
function Div
|
|
||||||
(Attr : League.JSON.Values.JSON_Value;
|
|
||||||
Content : League.JSON.Values.JSON_Value)
|
|
||||||
return League.JSON.Values.JSON_Value
|
|
||||||
is
|
|
||||||
Block : League.JSON.Objects.JSON_Object;
|
|
||||||
Out_Content : League.JSON.Arrays.JSON_Array;
|
|
||||||
begin
|
|
||||||
Block.Insert (
|
|
||||||
Type_String,
|
|
||||||
League.JSON.Values.To_JSON_Value (
|
|
||||||
Obj_String_Representation (Block_Div)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
Out_Content.Append (Attr);
|
|
||||||
Out_Content.Append (Content);
|
|
||||||
|
|
||||||
Block.Insert (
|
|
||||||
Content_String,
|
|
||||||
Out_Content.To_JSON_Value
|
|
||||||
);
|
|
||||||
|
|
||||||
return Block.To_JSON_Value;
|
|
||||||
end Div;
|
|
||||||
|
|
||||||
function Get_Type (B : League.JSON.Objects.JSON_Object)
|
|
||||||
return Object_Type is (Type_Mapping (B (Type_String).To_String));
|
|
||||||
|
|
||||||
begin
|
|
||||||
|
|
||||||
for Key in Object_Type loop
|
|
||||||
declare
|
|
||||||
Str_Rep : constant League.Strings.Universal_String :=
|
|
||||||
Obj_String_Representation (Key);
|
|
||||||
begin
|
|
||||||
Type_Mapping.Insert (Str_Rep, Key);
|
|
||||||
end;
|
|
||||||
end loop;
|
|
||||||
|
|
||||||
end Pandoc;
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
with Ada.Containers;
|
|
||||||
with Ada.Containers.Hashed_Maps;
|
|
||||||
with League.JSON.Objects;
|
|
||||||
with League.Strings.Hash;
|
|
||||||
with League.Strings;
|
|
||||||
with League.JSON.Values;
|
|
||||||
|
|
||||||
package Pandoc is
|
|
||||||
|
|
||||||
type String_Array is array (Natural range <>) of
|
|
||||||
League.Strings.Universal_String;
|
|
||||||
|
|
||||||
type Object_Type is
|
|
||||||
(Block_Plain,
|
|
||||||
Block_Para,
|
|
||||||
Block_LineBlock,
|
|
||||||
Block_CodeBlock,
|
|
||||||
Block_RawBlock,
|
|
||||||
Block_BlockQuote,
|
|
||||||
Block_OrderedList,
|
|
||||||
Block_BulletList,
|
|
||||||
Block_DefinitionList,
|
|
||||||
Block_Header,
|
|
||||||
Block_HorizontalRule,
|
|
||||||
Block_Table,
|
|
||||||
Block_Figure,
|
|
||||||
Block_Div,
|
|
||||||
Inline_String,
|
|
||||||
Inline_Emph,
|
|
||||||
Inline_Underline,
|
|
||||||
Inline_Strong,
|
|
||||||
Inline_Strikeout,
|
|
||||||
Inline_Superscript,
|
|
||||||
Inline_Subscript,
|
|
||||||
Inline_SmallCaps,
|
|
||||||
Inline_Quoted,
|
|
||||||
Inline_Cite,
|
|
||||||
Inline_Code,
|
|
||||||
Inline_Space,
|
|
||||||
Inline_SoftBreak,
|
|
||||||
Inline_LineBreak,
|
|
||||||
Inline_Math,
|
|
||||||
Inline_RawInline,
|
|
||||||
Inline_Link,
|
|
||||||
Inline_Image,
|
|
||||||
Inline_Note,
|
|
||||||
Inline_Span);
|
|
||||||
|
|
||||||
type Content_Arr is array (Natural range <>)
|
|
||||||
of League.JSON.Values.JSON_Value;
|
|
||||||
|
|
||||||
function Get_Type (B : League.JSON.Objects.JSON_Object) return Object_Type;
|
|
||||||
|
|
||||||
function "+" (T : Wide_Wide_String) return League.Strings.Universal_String
|
|
||||||
renames League.Strings.To_Universal_String;
|
|
||||||
|
|
||||||
function Attr
|
|
||||||
(Key : League.Strings.Universal_String;
|
|
||||||
Value : League.Strings.Universal_String;
|
|
||||||
Id : League.Strings.Universal_String :=
|
|
||||||
League.Strings.Empty_Universal_String)
|
|
||||||
return League.JSON.Values.JSON_Value;
|
|
||||||
|
|
||||||
function Attr
|
|
||||||
(Id : League.Strings.Universal_String;
|
|
||||||
Key : String_Array;
|
|
||||||
Value : String_Array) return League.JSON.Values.JSON_Value;
|
|
||||||
|
|
||||||
function Div
|
|
||||||
(Attr : League.JSON.Values.JSON_Value;
|
|
||||||
Content : Content_Arr) return League.JSON.Values.JSON_Value;
|
|
||||||
|
|
||||||
function Div
|
|
||||||
(Attr : League.JSON.Values.JSON_Value;
|
|
||||||
Content : League.JSON.Values.JSON_Value)
|
|
||||||
return League.JSON.Values.JSON_Value;
|
|
||||||
|
|
||||||
Type_String : constant League.Strings.Universal_String := +"t";
|
|
||||||
Content_String : constant League.Strings.Universal_String := +"c";
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
Obj_String_Representation :
|
|
||||||
constant array (Object_Type) of League.Strings.Universal_String := (
|
|
||||||
+"Plain",
|
|
||||||
+"Para",
|
|
||||||
+"LineBlock",
|
|
||||||
+"CodeBlock",
|
|
||||||
+"RawBlock",
|
|
||||||
+"BlockQuote",
|
|
||||||
+"OrderedList",
|
|
||||||
+"BulletList",
|
|
||||||
+"DefinitionList",
|
|
||||||
+"Header",
|
|
||||||
+"HorizontalRule",
|
|
||||||
+"Table",
|
|
||||||
+"Figure",
|
|
||||||
+"Div",
|
|
||||||
+"Str",
|
|
||||||
+"Emph",
|
|
||||||
+"Underline",
|
|
||||||
+"Strong",
|
|
||||||
+"Strikeout",
|
|
||||||
+"Superscript",
|
|
||||||
+"Subscript",
|
|
||||||
+"SmallCaps",
|
|
||||||
+"Quoted",
|
|
||||||
+"Cite",
|
|
||||||
+"Code",
|
|
||||||
+"Space",
|
|
||||||
+"SoftBreak",
|
|
||||||
+"LineBreak",
|
|
||||||
+"Math",
|
|
||||||
+"RawInline",
|
|
||||||
+"Link",
|
|
||||||
+"Image",
|
|
||||||
+"Note",
|
|
||||||
+"Span"
|
|
||||||
);
|
|
||||||
|
|
||||||
package Type_Map is new Ada.Containers.Hashed_Maps (
|
|
||||||
Key_Type => League.Strings.Universal_String,
|
|
||||||
Element_Type => Object_Type,
|
|
||||||
Hash => League.Strings.Hash,
|
|
||||||
Equivalent_Keys => League.Strings."=");
|
|
||||||
|
|
||||||
Type_Mapping : Type_Map.Map := Type_Map.Empty;
|
|
||||||
|
|
||||||
end Pandoc;
|
|
||||||
Loading…
Reference in New Issue
Block a user