I love Joseph Wright's model dtx file for style file creation, but would like to use it for classes, too. So I did some replacements in it (sty -> cls and the like) and got this democls.dtx:
% \iffalse meta-comment
% !TEX program = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*readme>
----------------------------------------------------------------
democls --- description text
E-mail: you@your.domain
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
Some text about the class: probably the same as the abstract.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
----------------------------------------------------------------
democls --- description text
E-mail: you@your.domain
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
\endpreamble
\postamble
Copyright (C) 2009 by You <you@your.domain>
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
version 1.3c of this license or (at your option) any later
version. The latest version of this license is in the file:
http://www.latex-project.org/lppl.txt
This work is "maintained" (as per LPPL maintenance status) by
You.
This work consists of the file democls.dtx
and the derived files democls.ins,
democls.pdf and
democls.cls.
\endpostamble
\usedir{tex/latex/democls}
\generate{
\file{\jobname.cls}{\from{\jobname.dtx}{class}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/democls}
\generate{
\file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/democls}
\generate{
\file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal>
%<*class>
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{democls}[2009/10/06 v1.0 description text]
%</class>
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[numbered]{hypdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\GetFileInfo{\jobname.cls}
%
%\title{^^A
% \textsf{democls} --- description text\thanks{^^A
% This file describes version \fileversion, last revised \filedate.^^A
% }^^A
%}
%\author{^^A
% You\thanks{E-mail: you@your.domain}^^A
%}
%\date{Released \filedate}
%
%\maketitle
%
%\changes{v1.0}{2009/10/06}{First public release}
%
%\DescribeMacro{\examplemacro}
% Some text about an example macro called \cs{examplemacro}, which
% might have an optional argument \oarg{arg1} and mandatory one
% \marg{arg2}.
%
%\StopEventually{^^A
% \PrintChanges
% \PrintIndex
%}
%
% \begin{macrocode}
%<*class>
% \end{macrocode}
%
%\begin{macro}{\examplemacro}
%\changes{v1.0}{2009/10/06}{Some change from the previous version}
% \begin{macrocode}
\newcommand*\examplemacro[2][]{%
Some code here, probably
}
% \end{macrocode}
%\end{macro}
%
% \begin{macrocode}
%</class>
% \end{macrocode}
%\Finale
However, compiling the dtx file shows that \filedate and \fileversion, generated by \GetFileInfo got wrong values:

There has been a comment by @MartinScharrer to a related question saying:
However, I guess the cause of trouble is the \ProvidesClass line before the \documentclass. It should be there, at least not in this form, because it is taken as part of the driver document. There are some \iffalse .. \fi missing or use %<class>\ProvidesClass instead.
I have been moving around stuff in my democls.dtx to no avail. How can I get this working?
\ProvidesPackageline to the start of the documented code part. Perhaps I should do a new blog post on this! – Joseph Wright Sep 27 '12 at 14:08