import sys
PATH = "D:/Projektit/DirectPython11/Modules/d3d11c.py"
HEADER = """
The :mod:`d3d11c` Module
----------------------------
.. module:: d3d11c
DirectPython constants module. Most constants are directly from SDK-headers.
Certain prefixes are usually removed, for example ``D3D11_BLEND_ZERO`` in C-code
would be ``BLEND_ZERO`` (the ``D3D11_``-prefix is removed) in DirectPython.
All .fx-files use the same notation.
This module is usually imported with ``from d3d11 import *``, but you don't have
to if you don't want to clutter your namespace. You can use ``import d3d11c``
and access them by their module name (``d3d11c.BLEND_ZERO``).
============================
Constants
============================
"""
D3DHEADER = """
------------------------------
Direct3D 11 constants
------------------------------
"""
WINHEADER = """
------------------------------
Windows constants
------------------------------
"""
SUBHEADER = """
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%s
"""
input = open(PATH)
d3dlines = []
winlines = []
active = None
winstarts = ("| SW_", "| VK_", "| WM_", "MB_", "| ID_", "| IDC_")
def write(text):
active.append(text)
for line in input:
stripped = line.strip()
if stripped.startswith("#"):
active = d3dlines
for x in winstarts:
if stripped.find(x) != -1:
active = winlines
break
parts = stripped.split("|")
www = ""
if len(parts) > 1:
write("\n.. _%s:\n" % parts[1].strip())
line = parts[0].strip()
if len(parts) >= 3:
www = "MSDN: " + parts[2]
write(SUBHEADER % (line[1:], www + "\n"))
elif stripped:
#write("* " + stripped.split()[0] + "\n")
write(".. data:: " + stripped.split()[0] + "\n")
output = open("d3d11c.rst", "w")
output.write(HEADER)
output.write(D3DHEADER)
for x in d3dlines:
output.write(x)
output.write(WINHEADER)
for x in winlines:
output.write(x)