From inside the client you can run:
    - docwritebaseref
    and
    - docwritetodoref
By passing "1" it'll write all idents, but that includes stuff like "_CAS_serverpass" and "__DEFAULT_SCOREBOARD", so only look into that list if you feel something was missed without it.
    - docwritetodoref 1

There's no real automation for incorporating these snippets, you will need to find the proper section to place them in and collect all the required properties.
You may encounter html-like-entities, like "gt;" (not "&gt;"!) in the autogenerated lists – the reference.xml would have "gt;=" as '''<command name=">=">''' in plain.

The established documentation does not adhere to any specific order of the properties; we would suggest to stick to one though and possibly fix the order if you see something not matching it.
Here's a set of fictional fully expanded examples:

        <variable name="settingsvalue">
          <description>Keep the value of <i>that</i> setting.</description>
          <remarks>
            <remark>A value between negative and positive infinity.</remark>
          </remarks>
          <examples>
            <example>
              <code>-1001, -3.1415, -1, 2, 6.28, 2002, …</code>
            </example>
          </examples>
          <value token="A" description="apparently a number" minValue="-∞" maxValue="+∞" defaultValue="0"/>
          <references>
            <identifierReference identifier="valuesettings"/>
          </references>
        </variable>


        <scriptalias name="add2alias">
          <!-- like command below -->
        </scriptalias>

        <command name="workworkwork">
          <description>Performs some work.</description>
          <remarks>
            <remark>This takes the potential and releases it's energy.</remark>
            <remark>2nd law of thermodynamics applies.</remark>
          </remarks>
          <defaultKeys>
            <key alias="F123" description="please do not press this button again"/>
          </defaultKeys>
          <examples>
            <example>
              <code><![CDATA[echo (workworkwork 42)]]></code>
              <explanation>Output: 41</explanation>
            </example>
          </examples>
          <remarks>
            <remark>
              Example: echo the energy of 1kg of sugar is (workworkwork 123456 "sugar rush")
            </remark>
          </remarks>
          <arguments>
            <argument token="A" description="the energy"/>
            <argument token="B" description="some comment"/>
          </arguments>
          <return token="N" description="the energy"/>
          <references>
            <identifierReference identifier="lazysundayafternoon"/>
          </references>
        </command>

For comparing established documentation and autogenerated I used this (on *nix):
    while read begriff; do 
        zahl=$(grep -c "name=\"${begriff}\"" docs/reference.xml); 
        if [ $zahl -eq 0 ]; then 
            echo $begriff; 
        fi; 
    done < <(grep name= docs/autogenerated_base_reference.xml|sed 's/^.*name="\([^"]*\)".*$/\1/')
