How to make a Text File dependent of an Armature object so that it appends with it to other projects?
PointerProperty

Another method would be to associate the text with the armature object or armature itself using a bpy.props.PointerProperty(type=bpy.types.Text)

import bpy
from bpy.props import PointerProperty

bpy.types.Armature.script_file = PointerProperty(type=bpy.types.Text)


As shown in this answer can poll the property. Another test script with a sample UI panel and the text associated to an armature object.

import bpy    

class OBJECT_PT_HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    #poll for armature object
    @classmethod
    def poll(cls, context):
        return context.object and context.object.type == 'ARMATURE'

    def draw(self, context):
        layout = self.layout
        arm_ob = context.object
        layout.prop(arm_ob, "rig_script")

def is_armature_object(self, object):
    return self.type == 'ARMATURE'


def register():
    bpy.utils.register_class(OBJECT_PT_HelloWorldPanel)
    bpy.types.Object.rig_script = bpy.props.PointerProperty(
        type=bpy.types.Text,
        poll=is_armature_object,
    )


def unregister():
    bpy.utils.unregister_class(OBJECT_PT_HelloWorldPanel)
    del bpy.types.Object.rig_script


if __name__ == "__main__":
    register()