{"id":1451,"date":"2018-01-19T19:22:51","date_gmt":"2018-01-19T19:22:51","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/how-to-document-your-php-classes-page-5\/"},"modified":"2018-01-19T19:24:48","modified_gmt":"2018-01-19T19:24:48","slug":"how-to-document-your-php-classes-page-5","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/how-to-document-your-php-classes-page-5\/","title":{"rendered":"How To Document Your PHP Classes Page 5"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Stefano Locati<\/div>\n<div class=\"\">on August 25, 2000<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<h2>How To Modify The Script For PHP<\/h2>\n<div class=\"articlePara\">\nThe original HeaderDoc script from Apple is meant for C or C++ headers, so it has to be slightly<br \/>\nmodified to use it with PHP. If you&#8217;re not interested about details you can just<br \/>\n<a href=\"http:\/\/www.stefanolocati.it\/download\/headerdoc-2-ste.tgz\" target=\"_blank\">download<\/a> it and<br \/>\nskip to the next section.<\/div>\n<div class=\"articlePara\">\nThe only thing to modify in the sources is in the main perl file and it&#8217;s made to make the script accept<br \/>\n.php and .php3 extensions.<\/div>\n<div class=\"articlePara\">\n<pre>\n$ diff headerDoc2HTML.pl \/usr\/local\/bin\/headerdoc2html\n195c195\n&lt;     ($rootFileName = $filename) =~ s\/.(h|i)$\/\/;\n---\n&gt;     ($rootFileName = $filename) =~ s\/.(h|i|php|php3)$\/\/;\n<\/pre>\n<\/div>\n<h2>Running The Script<\/h2>\n<div class=\"articlePara\">\nAfter having installed the script, supposing that your classes are in the classes subdirectory and<br \/>\nthat you want to put the generated documentation in the docs directory, you should issue this command:<\/div>\n<div class=\"example\">\n<pre>\nheaderdoc2html -o docs classes\/*.php\n<\/pre>\n<\/div>\n<div class=\"articlePara\">\nUnfortunately if there are multiple PHP files, this script has the bad habit to split those files in different<br \/>\ndirectories, making navigation among classes&#8217; documentation more difficoult. Moreover since the original script<br \/>\nwas written for C\/C++ header files that are just declarations of classes and functions and have no definitions<br \/>\nfor them, it outputs all the code following the function name until a <code class=\"example\">;<\/code> is found, so tipically<br \/>\nthe first line of code.<\/div>\n<div class=\"articlePara\">\nBut before you get desperate after all the effort reading till now, relax because I wrote a simple script to<br \/>\nsolve both these problems.<\/div>\n<div class=\"example\">\n<pre>\ncat classes\/*.php | sed 's\/ *{\/;#{\/g' | tr \"#\" \"n\" &gt; docs\/all.php\nheaderdoc2html -o docs docs\/all.php\nrm docs\/all.php\n<\/pre>\n<\/div>\n<div class=\"articlePara\">\nIf you&#8217;re wondering why I use the tr utility here instead of doing all the job with sed, the reason<br \/>\nis that sed 3.02 that is still used on RedHat 6.2 doesn&#8217;t handle newlines. The new version sed 3.02a<br \/>\nwould be needed instead. If you&#8217;re curious see the<br \/>\n<a href=\"http:\/\/www.cornerstonemag.com\/sed\/sedfaq.html\" target=\"_blank\">SED FAQ<\/a>.<\/div>\n<div class=\"articlePara\">\n Good luck with your documentation effort!<\/div>\n<div class=\"articlePara\">\n<a href=\"http:\/\/www.stefanolocati.it\/\" target=\"_blank\">Stefano Locati<\/a><\/div>\n<div class=\"articlePara\">\n&#8211;Stefano\n<\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"stefano20000824fdb0.html?page=4\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"stefano20000824.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"stefano200008244658.html?page=2\">2<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"stefano200008249ba9.html?page=3\">3<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"stefano20000824fdb0.html?page=4\">4<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">5<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>By Stefano Locati on August 25, 2000 How To Modify The Script For PHP The original HeaderDoc script from Apple is meant for C or C++ headers, so it has to be slightly modified to use it with PHP. If you&#8217;re not interested about details you can just download it&#8230; <a href=\"https:\/\/phpbuilder.com\/how-to-document-your-php-classes-page-5\/\" class=\"readmore\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1451","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1451"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1451\/revisions"}],"predecessor-version":[{"id":3307,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1451\/revisions\/3307"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}