From 24415920ff7ee31b294d785e776a2a7dd2ad6367 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Dec 2010 00:24:59 +0000 Subject: wrongdoc 1.0.0 - initial release Welcome to hell --- .document | 8 + .gitignore | 10 + .wrongdoc.yml | 7 + COPYING | 674 ++++++++++++++++ Documentation/.gitignore | 4 + Documentation/GNUmakefile | 32 + Documentation/dotwrongdoc.5.ronn | 23 + Documentation/wrongdoc.1.ronn | 17 + GIT-VERSION-GEN | 40 + GNUmakefile | 114 +++ LICENSE | 17 + README | 40 + bin/wrongdoc | 20 + dotwrongdoc_5 | 0 lib/wrongdoc.rb | 35 + lib/wrongdoc/changelog.rb | 25 + lib/wrongdoc/final.rb | 105 +++ lib/wrongdoc/gemspec.rb | 18 + lib/wrongdoc/history.rb | 50 ++ lib/wrongdoc/merge.rb | 20 + lib/wrongdoc/news_atom.rb | 46 ++ lib/wrongdoc/news_rdoc.rb | 30 + lib/wrongdoc/parse_xml.rb | 11 + lib/wrongdoc/prepare.rb | 17 + lib/wrongdoc/rdoc.rb | 68 ++ lib/wrongdoc/rdoc_options.rb | 11 + lib/wrongdoc/readme.rb | 20 + lib/wrongdoc/release.rb | 44 ++ setup.rb | 1586 ++++++++++++++++++++++++++++++++++++++ wrongdoc.gemspec | 27 + wrongdoc_1 | 0 31 files changed, 3119 insertions(+) create mode 100644 .document create mode 100644 .gitignore create mode 100644 .wrongdoc.yml create mode 100644 COPYING create mode 100644 Documentation/.gitignore create mode 100644 Documentation/GNUmakefile create mode 100644 Documentation/dotwrongdoc.5.ronn create mode 100644 Documentation/wrongdoc.1.ronn create mode 100755 GIT-VERSION-GEN create mode 100644 GNUmakefile create mode 100644 LICENSE create mode 100644 README create mode 100644 bin/wrongdoc create mode 100644 dotwrongdoc_5 create mode 100644 lib/wrongdoc.rb create mode 100644 lib/wrongdoc/changelog.rb create mode 100644 lib/wrongdoc/final.rb create mode 100644 lib/wrongdoc/gemspec.rb create mode 100644 lib/wrongdoc/history.rb create mode 100644 lib/wrongdoc/merge.rb create mode 100644 lib/wrongdoc/news_atom.rb create mode 100644 lib/wrongdoc/news_rdoc.rb create mode 100644 lib/wrongdoc/parse_xml.rb create mode 100644 lib/wrongdoc/prepare.rb create mode 100644 lib/wrongdoc/rdoc.rb create mode 100644 lib/wrongdoc/rdoc_options.rb create mode 100644 lib/wrongdoc/readme.rb create mode 100644 lib/wrongdoc/release.rb create mode 100644 setup.rb create mode 100644 wrongdoc.gemspec create mode 100644 wrongdoc_1 diff --git a/.document b/.document new file mode 100644 index 0000000..785aa7d --- /dev/null +++ b/.document @@ -0,0 +1,8 @@ +ChangeLog +lib +NEWS +README +LATEST +LICENSE +wrongdoc_1 +dotwrongdoc_5 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..50d99eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/.manifest +/GIT-VERSION-FILE +/ChangeLog +/LATEST +/NEWS +/.config +/InstalledFiles +/doc +/man +/pkg diff --git a/.wrongdoc.yml b/.wrongdoc.yml new file mode 100644 index 0000000..7c786b6 --- /dev/null +++ b/.wrongdoc.yml @@ -0,0 +1,7 @@ +--- +cgit_url: http://git.bogomips.org/cgit/wrongdoc.git +git_url: git://git.bogomips.org/wrongdoc.git +rdoc_url: http://bogomips.org/wrongdoc/ +merge_html: + wrongdoc_1: Documentation/wrongdoc.1.html_fragment + dotwrongdoc_5: Documentation/dotwrongdoc.5.html_fragment diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..b27ad83 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Documentation/.gitignore b/Documentation/.gitignore new file mode 100644 index 0000000..c618f1a --- /dev/null +++ b/Documentation/.gitignore @@ -0,0 +1,4 @@ +*.html_fragment +*.1 +*.5 +*.html diff --git a/Documentation/GNUmakefile b/Documentation/GNUmakefile new file mode 100644 index 0000000..33fdb87 --- /dev/null +++ b/Documentation/GNUmakefile @@ -0,0 +1,32 @@ +all:: + +RONN = ronn +ronn_man = $(RONN) -r +ronn_html = $(RONN) -f + +man1 := $(addsuffix .1,wrongdoc) +html1 := $(addsuffix .html_fragment,$(man1)) +man5 := $(addsuffix .5,dotwrongdoc) +html5 := $(addsuffix .html_fragment,$(man5)) +man := $(man1) $(man5) +html := $(html1) $(html5) + +all:: html man + +html: $(html) +man: $(man) + mkdir -p ../man/man1 ../man/man5 + install -m 644 $(man1) ../man/man1 + install -m 644 $(man5) ../man/man5 + +%.1: %.1.ronn + $(ronn_man) $< +%.5: %.5.ronn + $(ronn_man) $< +%.1.html_fragment: %.1.ronn + $(ronn_html) $< +%.5.html_fragment: %.5.ronn + $(ronn_html) $< + +clean:: + $(RM) $(man) $(html) diff --git a/Documentation/dotwrongdoc.5.ronn b/Documentation/dotwrongdoc.5.ronn new file mode 100644 index 0000000..5c42a83 --- /dev/null +++ b/Documentation/dotwrongdoc.5.ronn @@ -0,0 +1,23 @@ +dotwrongdoc(5) -- wrongdoc config file format +============================================= + +## SYNOPSIS + +A YAML file in the top-level project directory named ".wrongdoc.yml" + +## DESCRIPTION + +As wrongdoc favors consistency over configuration, there is minimal +configuration to deal with. + +## KEYS + +`rdoc_url`, `cgit_url` should be obvious + +`merge_html` is a key-value mapping of (empty) RDoc source files to an +HTML file that will be merged into RDoc after-the-fact. It is useful +for merging non-RDoc generated HTML into the project. + +## SEE ALSO + +wrongdoc(1) diff --git a/Documentation/wrongdoc.1.ronn b/Documentation/wrongdoc.1.ronn new file mode 100644 index 0000000..803ad28 --- /dev/null +++ b/Documentation/wrongdoc.1.ronn @@ -0,0 +1,17 @@ +wrongdoc(1) -- removes JavaScript from RDoc +=========================================== + +## SYNOPSIS +`wrongdoc` prepare + +`wrongdoc` + +## DESCRIPTION + +**Wrongdoc** does horrible things to your RDoc project. It's own +documentation sucks, but it'll help to make your documentation +JavaScript-free and therefore suck less :) + +## SEE ALSO + +dotwrongdoc(5) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN new file mode 100755 index 0000000..88b943a --- /dev/null +++ b/GIT-VERSION-GEN @@ -0,0 +1,40 @@ +#!/bin/sh + +GVF=GIT-VERSION-FILE +DEF_VER=v1.0.0.GIT + +LF=' +' + +# First see if there is a version file (included in release tarballs), +# then try git-describe, then default. +if test -f version +then + VN=$(cat version) || VN="$DEF_VER" +elif test -d .git -o -f .git && + VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && + case "$VN" in + *$LF*) (exit 1) ;; + v[0-9]*) + git update-index -q --refresh + test -z "$(git diff-index --name-only HEAD --)" || + VN="$VN-dirty" ;; + esac +then + VN=$(echo "$VN" | sed -e 's/-/./g'); +else + VN="$DEF_VER" +fi + +VN=$(expr "$VN" : v*'\(.*\)') + +if test -r $GVF +then + VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) +else + VC=unset +fi +test "$VN" = "$VC" || { + echo >&2 "GIT_VERSION = $VN" + echo "GIT_VERSION = $VN" >$GVF +} diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..d206a81 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,114 @@ +# use GNU Make to run tests in parallel, and without depending on RubyGems +all:: +MRI = ruby +RUBY = ruby +RAKE = rake +RSYNC = rsync +WRONGDOC := $(RUBY) -I lib bin/wrongdoc + +GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE + @./GIT-VERSION-GEN +-include GIT-VERSION-FILE +-include local.mk + +man1_paths := $(addprefix man/man1/, wrongdoc.1) +man5_paths := $(addprefix man/man5/, dotwrongdoc.5) +manpages := $(man1_paths) $(man5_paths) + +clean: + -$(MAKE) -C Documentation clean + +man html: + $(MAKE) -C Documentation $@ + +$(manpages): man +pkg_extra := GIT-VERSION-FILE ChangeLog LATEST NEWS $(manpages) + +ChangeLog: GIT-VERSION-FILE .wrongdoc.yml + $(WRONGDOC) prepare + +.manifest: ChangeLog + (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \ + LC_ALL=C sort > $@+ + mv $@+ $@ + +doc: .document .wrongdoc.yml man html + find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';' + $(RM) -r doc + $(WRONGDOC) all + install -m644 COPYING doc/COPYING + install -m644 $(shell grep '^[A-Z]' .document) doc/ + tar cf - man | (cd doc && tar xf -) + +publish_doc: + -git set-file-times + $(MAKE) doc + -find doc/images -type f | \ + TZ=UTC xargs touch -d '1970-01-01 00:00:01' doc/rdoc.css + chmod 644 $$(find doc -type f) + $(RSYNC) -av doc/ bogomips.org:/srv/bogomips/wrongdoc/ + git ls-files | xargs touch + +ifneq ($(VERSION),) +rfproject := rainbows +rfpackage := wrongdoc +pkggem := pkg/$(rfpackage)-$(VERSION).gem +pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz +release_notes := release_notes-$(VERSION) +release_changes := release_changes-$(VERSION) + +release-notes: $(release_notes) +release-changes: $(release_changes) +$(release_changes): + $(WRONGDOC) release_changes > $@+ + $(VISUAL) $@+ && test -s $@+ && mv $@+ $@ +$(release_notes): + $(WRONGDOC) release_notes > $@+ + $(VISUAL) $@+ && test -s $@+ && mv $@+ $@ + +# ensures we're actually on the tagged $(VERSION), only used for release +verify: + test x"$(shell umask)" = x0022 + git rev-parse --verify refs/tags/v$(VERSION)^{} + git diff-index --quiet HEAD^0 + test `git rev-parse --verify HEAD^0` = \ + `git rev-parse --verify refs/tags/v$(VERSION)^{}` + +fix-perms: + -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644 + -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755 + +gem: $(pkggem) + +install-gem: $(pkggem) + gem install $(CURDIR)/$< + +$(pkggem): .manifest fix-perms + gem build $(rfpackage).gemspec + mkdir -p pkg + mv $(@F) $@ + +$(pkgtgz): distdir = $(basename $@) +$(pkgtgz): HEAD = v$(VERSION) +$(pkgtgz): .manifest fix-perms + @test -n "$(distdir)" + $(RM) -r $(distdir) + mkdir -p $(distdir) + tar cf - `cat .manifest` | (cd $(distdir) && tar xf -) + cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+ + mv $@+ $@ + +package: $(pkgtgz) $(pkggem) + +release: verify package $(release_notes) $(release_changes) + rubyforge add_release -f -n $(release_notes) -a $(release_changes) \ + $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz) + gem push $(pkggem) + -rubyforge add_file \ + $(rfproject) $(rfpackage) $(VERSION) $(pkggem) +else +gem install-gem: GIT-VERSION-FILE + $(MAKE) $@ VERSION=$(GIT_VERSION) +endif + +.PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5ba39f5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +wrongdoc is copyrighted Free Software by all contributors, see logs in +revision control for names and email addresses of all of them. + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version +{3}[http://www.gnu.org/licenses/gpl-3.0.txt] of the License, or (at +your option) any later version. + +wrongdoc is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with wrongdoc; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 diff --git a/README b/README new file mode 100644 index 0000000..c768423 --- /dev/null +++ b/README @@ -0,0 +1,40 @@ += wrongdoc - RDoc done right (IMNSHO) + +wrongdoc mangles an existing RDoc directory and makes any changes we +feel like. It mainly removes JavaScript from Darkfish and adds links to +a {cgit}[http://hjemli.net/git/cgit/] instance. It is a bikeshed +project and *entirely* subject to the whims of its creator, so it is +likely the wrong solution for anybody else. + +wrongdoc is tightly integrated with git and cgit, and capable of of +automatically generating NEWS and ChangeLog files in RDoc format based +on git history and tags. + +== Usage + +First, prepare a .wrongdoc.yml in the top-level directory of your project, +then run the following command to generate your RDoc: + + $ wrongdoc + +== Future Plans + +* Remove images/icons from Darkfish without breaking text alignment. + +* Optimize for small screens at the expense of large ones. + +* gitweb support (preserving cgit support) + +* ASCII-art unicorns and rainbows! (maybe) + +== Feedback + +It's Free Software, fork it and hack it to your heart's content, just +do not expect the original author(s) to support anything they disagree +with. Remember, this is a bikeshed project! + +Help with CSS for removing image/icon cruft and making better use of +small screen real-estate would be greatly appreciated. + +The original authors may be contacted through the mailing list: +{wrongdoc@librelist.org}[mailto:wrongdoc@librelist.org]. diff --git a/bin/wrongdoc b/bin/wrongdoc new file mode 100644 index 0000000..d33feda --- /dev/null +++ b/bin/wrongdoc @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +usage = "Usage: #{File.basename($0)} [prepare]" +$stderr.sync = $stdout.sync = true +require 'wrongdoc' +opts = Wrongdoc.config +case ARGV[0] +when "prepare" + Wrongdoc::Prepare.new(opts).run +when "release_notes" + Wrongdoc::Release.notes($stdout, opts) +when "release_changes" + Wrongdoc::Release.changes($stdout) +when "all" + Wrongdoc::Prepare.new(opts).run + Wrongdoc::Rdoc.new(opts).run + Wrongdoc::Merge.new(opts).run + Wrongdoc::Final.new(opts, ARGV[1]).run +else + abort "#{$0.inspect} #{ARGV.inspect} not understood" +end diff --git a/dotwrongdoc_5 b/dotwrongdoc_5 new file mode 100644 index 0000000..e69de29 diff --git a/lib/wrongdoc.rb b/lib/wrongdoc.rb new file mode 100644 index 0000000..dfb41d6 --- /dev/null +++ b/lib/wrongdoc.rb @@ -0,0 +1,35 @@ +require 'tempfile' +require 'uri' +require 'yaml' +require 'tidy_ffi' +require 'nokogiri' + +module Wrongdoc + + # the version of wrongdoc, currently 1.0.0 + VERSION = '1.0.0' + + autoload :Readme, 'wrongdoc/readme' + autoload :History, 'wrongdoc/history' + autoload :Release, 'wrongdoc/release' + + autoload :Changelog, 'wrongdoc/changelog' + autoload :NewsRdoc, 'wrongdoc/news_rdoc' + autoload :NewsAtom, 'wrongdoc/news_atom' + autoload :ParseXML, 'wrongdoc/parse_xml' + + autoload :Prepare, 'wrongdoc/prepare' + autoload :Rdoc, 'wrongdoc/rdoc' + autoload :Merge, 'wrongdoc/merge' + autoload :Final, 'wrongdoc/final' + + autoload :Gemspec, 'wrongdoc/gemspec' + autoload :RdocOptions, 'wrongdoc/rdoc_options' + + def self.config(path = ".wrongdoc.yml") + File.exist?(path) or abort "#{path} not found in current directory" + opts = YAML.load(File.read(path)) + opts.keys.each { |k| opts[k.to_sym] = opts.delete(k) } # symbolize keys + opts + end +end diff --git a/lib/wrongdoc/changelog.rb b/lib/wrongdoc/changelog.rb new file mode 100644 index 0000000..f16bfbf --- /dev/null +++ b/lib/wrongdoc/changelog.rb @@ -0,0 +1,25 @@ +# helper method for generating the ChangeLog in RDoc format atomically +module Wrongdoc::Changelog + include Wrongdoc::History + + def changelog + fp = Tempfile.new('ChangeLog', '.') + fp.write "ChangeLog from #@cgit_uri" + cmd = %w(git log) + if @changelog_start && tags[0] + range = "#@changelog_start..#{tags[0][:tag]}" + fp.write(" (#{range})") + cmd << range + end + fp.write("\n\n") + prefix = " " + IO.popen(cmd.join(' ')) do |io| + io.each { |line| + fp.write prefix + fp.write line + } + end + File.rename(fp.path, 'ChangeLog') + fp.close! + end +end diff --git a/lib/wrongdoc/final.rb b/lib/wrongdoc/final.rb new file mode 100644 index 0000000..7070de8 --- /dev/null +++ b/lib/wrongdoc/final.rb @@ -0,0 +1,105 @@ +require 'find' +require 'fileutils' + +class Wrongdoc::Final + include Wrongdoc::ParseXML + include Wrongdoc::NewsAtom + + def run + Find.find('doc') { |path| /\.html\z/ =~ path and fix(path) } + FileUtils.rm_rf('doc/js') + news_atom + end + + def initialize(opts, git_tag = nil) + @cgit_uri = URI.parse(opts[:cgit_url]) + @rdoc_uri = URI.parse(opts[:rdoc_url]) + @git_tag = git_tag + end + + # returns a cgit URI for the given +path+ and +lineno+ + def path_uri(path, lineno) + uri = @cgit_uri.dup + uri.path += "/tree/#{URI.escape(path)}" + uri.fragment = "n#{lineno}" + uri.query = "id=#{URI.escape(@git_tag)}" if @git_tag + uri + end + + # delete all the stuff that offends us + def killkillkill!(doc) + unlink = proc { |node| node.unlink } + + # JavaScript is dangerous + doc.search("script").each(&unlink) + + # if your project's big enough to need JS search, it's too bloated + doc.search('span.search-toggle').each(&unlink) + doc.search('form').each(&unlink) + + # remove W3C validator link, we use tidy instead + doc.search('div#validator-badges p').each { |x| + /Validate/i =~ x.content and x.unlink + } + end + + # since we killed off JavaScript, viewing source isn't possible with + # RDoc anymore, so link people to the web source viewer + def source_linkify!(doc) + doc.search('div.method-detail').each { |mdetail| + path = lineno = nil + mdetail.search('div.method-source-code').each { |src| + src.search('span.ruby-comment').each { |x| + if x.content =~ /File\s+(\S+),\s+line\s+(\d+)/s + path, lineno = $1, $2 + end + } + src.unlink if path && lineno + } + if path && lineno + mdetail.search('span.method-click-advice').each { |x| + x.content = '' + a = Nokogiri::XML::Node.new('a', doc) + a['href'] = path_uri(path, lineno).to_s + a.content = 'view method source' + x.add_child(a) + } + end + } + end + + # Don't give the original Darkfish a bad name, and advertise ourselves :) + def advertise!(doc) + doc.search('div#validator-badges p small').each { |x| + if /\AGenerated/ =~ x.content + first = x.children.first + first.content = first.content.gsub /\AG/, "Originally g" + last = x.children.last + last.content = "#{last.content}, modified by " + + a = Nokogiri::XML::Node.new('a', doc) + a["href"] = "http://bogomips.org/wrongdoc/" + a.content = "wrongdoc" + last.add_next_sibling(a) + end + } + end + + def fix(file) + File.open(file, "a+") do |fp| + buf = process(fp.read) + fp.truncate 0 + fp.write buf + end + end + + # the main entry point, this does all the require processing on any + # given String buffer. + def process(str) + doc = parse_xml(str) + killkillkill!(doc) + source_linkify!(doc) + advertise!(doc) + doc.to_xhtml(:indent => 0) + end +end diff --git a/lib/wrongdoc/gemspec.rb b/lib/wrongdoc/gemspec.rb new file mode 100644 index 0000000..0d31ffd --- /dev/null +++ b/lib/wrongdoc/gemspec.rb @@ -0,0 +1,18 @@ +# helper methods for gemspecs +module Wrongdoc::Gemspec + include Wrongdoc::Readme + include Wrongdoc::RdocOptions + + def extra_rdoc_files(manifest) + File.readlines('.document').map! do |x| + x.chomp! + if File.directory?(x) + manifest.grep(%r{\A#{x}/}) + elsif File.file?(x) + x + else + nil + end + end.flatten.compact + end +end diff --git a/lib/wrongdoc/history.rb b/lib/wrongdoc/history.rb new file mode 100644 index 0000000..3443ca3 --- /dev/null +++ b/lib/wrongdoc/history.rb @@ -0,0 +1,50 @@ +module Wrongdoc::History + def initialize_history + @tags = @old_summaries = nil + end + + # returns a cgit URI for a given +tag_name+ + def tag_uri(tag_name) + uri = @cgit_uri.dup + uri.path = "/tag/" + uri.query = "id=#{tag_name}" + uri + end + + # TODO: investigate Ruby git libraries + def tags + timefmt = '%Y-%m-%dT%H:%M:%SZ' + @tags ||= `git tag -l`.split(/\n/).map do |tag| + next if tag == "v0.0.0" + if %r{\Av[\d\.]+} =~ tag + header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3) + header = header.split(/\n/) + tagger = header.grep(/\Atagger /).first + body ||= "initial" + time = Time.at(tagger.split(/ /)[-2].to_i).utc + { + :time => time.strftime(timefmt), + :ruby_time => time, + :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip, + :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip, + :id => `git rev-parse refs/tags/#{tag}`.chomp!, + :tag => tag, + :subject => subject, + :body => (old = old_summaries[tag]) ? "#{old}\n#{body}" : body, + } + end + end.compact.sort { |a,b| b[:time] <=> a[:time] } + end + + def old_summaries + @old_summaries ||= if File.exist?(".CHANGELOG.old") + File.readlines(".CHANGELOG.old").inject({}) do |hash, line| + version, summary = line.split(/ - /, 2) + hash[version] = summary + hash + end + else + {} + end + end +end diff --git a/lib/wrongdoc/merge.rb b/lib/wrongdoc/merge.rb new file mode 100644 index 0000000..b51ee5a --- /dev/null +++ b/lib/wrongdoc/merge.rb @@ -0,0 +1,20 @@ +class Wrongdoc::Merge + include Wrongdoc::ParseXML + + def initialize(opts) + @merge_html = opts[:merge_html] + end + + def run + @merge_html.each do |file, source| + rdoc_html = "doc/#{file}.html" + src = Nokogiri::XML(File.read(source)) + File.open(rdoc_html, "a+") { |fp| + doc = parse_xml(fp.read) + doc.search("div#documentation")[0].add_child(src.root) + fp.truncate 0 + fp.write doc.to_xhtml + } + end + end +end diff --git a/lib/wrongdoc/news_atom.rb b/lib/wrongdoc/news_atom.rb new file mode 100644 index 0000000..1e7a781 --- /dev/null +++ b/lib/wrongdoc/news_atom.rb @@ -0,0 +1,46 @@ +module Wrongdoc::NewsAtom + include Wrongdoc::History + include Wrongdoc::Readme + + # generates an Atom feed based on git tags in the document directory + def news_atom + project_name, short_desc, _ = x = readme_metadata + new_tags = tags[0,10] + atom_uri = @rdoc_uri.dup + atom_uri.path += "NEWS.atom.xml" + news_uri = @rdoc_uri.dup + news_uri.path += "NEWS.html" + doc = Nokogiri::XML::Builder.new { + feed :xmlns => "http://www.w3.org/2005/Atom" do + id! atom_uri.to_s + title "#{project_name} news" + subtitle short_desc + link! :rel => 'alternate', :type => 'text/html', :href => news_uri.to_s + updated new_tags.empty? ? '1970-01-01:00:00:00Z' : new_tags[0][:time] + new_tags.each do |tag| + entry { + title tag[:subject] + updated tag[:time] + published tag[:time] + author { + name tag[:tagger_name] + email tag[:tagger_email] + } + uri = tag_uri(tag[:tag]).to_s + link! :rel => "alternate", :type => "text/html", :href => uri + id! uri + message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s)[0].strip + content({:type =>:text}, message_only) + content(:type =>:xhtml) { pre tag[:body] } + } + end + end + } + fpath = "doc/NEWS.atom.xml" + File.open(fpath, "w") { |fp| fp.write doc.to_xml(:indent => 0) } + unless new_tags.empty? + time = new_tags[0][:ruby_time] + File.utime(time, time, fpath) + end + end +end diff --git a/lib/wrongdoc/news_rdoc.rb b/lib/wrongdoc/news_rdoc.rb new file mode 100644 index 0000000..ee21d6b --- /dev/null +++ b/lib/wrongdoc/news_rdoc.rb @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +module Wrongdoc::NewsRdoc + include Wrongdoc::History + + def puts_tag(fp, tag) + time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC') + fp.puts "=== #{tag[:subject]} / #{time}" + fp.puts "" + + body = tag[:body] + fp.puts tag[:body].gsub(/^/smu, " ").gsub(/[ \t]+$/smu, "") + fp.puts "" + end + + # generates a NEWS file in the top-level directory based on git tags + def news_rdoc + news = Tempfile.new('NEWS', '.') + tags.each { |tag| puts_tag(news, tag) } + File.open("LATEST", "wb") { |latest| + if tags.empty? + latest.puts "Currently unreleased" + news.puts "No news yet." + else + puts_tag(latest, tags[0]) + end + } + File.rename(news.path, 'NEWS') + news.close! + end +end diff --git a/lib/wrongdoc/parse_xml.rb b/lib/wrongdoc/parse_xml.rb new file mode 100644 index 0000000..6d7abe2 --- /dev/null +++ b/lib/wrongdoc/parse_xml.rb @@ -0,0 +1,11 @@ +module Wrongdoc::ParseXML + def parse_xml(str) + opts = { + :input_encoding => 'utf8', + :output_encoding => 'utf8', + :wrap => 0, + :tidy_mark => false, + } + Nokogiri::XML(TidyFFI::Tidy.new(str, opts).clean) + end +end diff --git a/lib/wrongdoc/prepare.rb b/lib/wrongdoc/prepare.rb new file mode 100644 index 0000000..85922ad --- /dev/null +++ b/lib/wrongdoc/prepare.rb @@ -0,0 +1,17 @@ +class Wrongdoc::Prepare + include Wrongdoc::NewsRdoc + include Wrongdoc::Changelog + include Wrongdoc::Readme + + def initialize(opts) + @rdoc_uri = URI.parse(opts[:rdoc_url]) + @cgit_uri = URI.parse(opts[:cgit_url]) + @changelog_start = opts[:changelog_start] + @name, @short_desc = readme_metadata + end + + def run + news_rdoc + changelog + end +end diff --git a/lib/wrongdoc/rdoc.rb b/lib/wrongdoc/rdoc.rb new file mode 100644 index 0000000..0b54aef --- /dev/null +++ b/lib/wrongdoc/rdoc.rb @@ -0,0 +1,68 @@ +# we won't deal with the non-Darkfish RDoc in older rubies, it has frames :< +if (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") && \ + RUBY_VERSION.to_f <= 1.8 + require 'rubygems' + gem 'rdoc', '~> 3.0.1' +end +require 'rdoc/rdoc' + +class Wrongdoc::Rdoc + include Wrongdoc::RdocOptions + include Wrongdoc::ParseXML + + def initialize(opts) + @rdoc_uri = URI.parse(opts[:rdoc_url]) + @cgit_uri = URI.parse(opts[:cgit_url]) + end + + def run(argv = []) + rdoc(argv) + add_atom("doc/ChangeLog.html", cgit_atom_uri) + add_atom("doc/NEWS.html", news_atom_uri) + add_atom("doc/README.html", news_atom_uri) + + # the stock RDoc index page layout lacks a vertical sidebar full of links + rdoc_index = "doc/rdoc_index.html" + File.exist?(rdoc_index) and File.unlink(rdoc_index) + File.rename("doc/index.html", rdoc_index) + File.link("doc/README.html", "doc/index.html") + end + + def rdoc(argv) + r = RDoc::RDoc.new + r.document(rdoc_options.concat(argv)) + end + + def add_atom(path, atom_uri) + File.open(path, "a+") do |fp| + doc = parse_xml(fp.read) + doc.search("title").each { |t| + t.add_next_sibling(atom_node(doc, atom_uri)) + } + fp.truncate 0 + fp.write doc.to_xhtml + end + end + + def cgit_atom_uri + uri = @cgit_uri.dup + uri.path += "/atom/" + uri.query = "h=master" + uri + end + + def news_atom_uri + uri = @rdoc_uri.dup + uri.path += "NEWS.atom.xml" + uri + end + + def atom_node(doc, uri, title = 'Atom feed') + link = Nokogiri::XML::Node.new('link', doc) + link['rel'] = 'alternate' + link['title'] = title + link['href'] = uri.to_s + link['type'] = 'application/atom+xml' + link + end +end diff --git a/lib/wrongdoc/rdoc_options.rb b/lib/wrongdoc/rdoc_options.rb new file mode 100644 index 0000000..15474f4 --- /dev/null +++ b/lib/wrongdoc/rdoc_options.rb @@ -0,0 +1,11 @@ +module Wrongdoc::RdocOptions + include Wrongdoc::Readme + + def rdoc_options + webcvs = URI.parse(Wrongdoc.config[:cgit_url]) + webcvs.path += "/tree" + webcvs = "#{webcvs}/%s" + _, _, title = readme_metadata + [ '-t', title, '-W', webcvs ] + end +end diff --git a/lib/wrongdoc/readme.rb b/lib/wrongdoc/readme.rb new file mode 100644 index 0000000..8c5f5b6 --- /dev/null +++ b/lib/wrongdoc/readme.rb @@ -0,0 +1,20 @@ +# helpers for parsing the top-level README file (no suffix support :P) +module Wrongdoc::Readme + + # returns a one-paragraph summary from the README + def readme_description + File.read("README").split(/\n\n/)[1] + end + + # parses the README file in the top-level directory for project metadata + def readme_metadata + l = File.readlines("README")[0].strip! + l.gsub!(/^=\s+/, '') or abort "#{l.inspect} doesn't start with '='" + title = l.dup + if l.gsub!(/^(\w+\!)\s+/, '') # Rainbows! + return $1, l, title + else + return (l.split(/\s*[:-]\s*/, 2)).push(title) + end + end +end diff --git a/lib/wrongdoc/release.rb b/lib/wrongdoc/release.rb new file mode 100644 index 0000000..f6c72e5 --- /dev/null +++ b/lib/wrongdoc/release.rb @@ -0,0 +1,44 @@ +module Wrongdoc::Release + self.extend Wrongdoc::History + + def self.changes(io) + vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort + cmds = [] + if vtags.empty? + cmds << %w(git log) + else + version = vtags[0] + prev = vtags[vtags.index(version) - 1] + if prev + cmds << [ 'git', 'diff', '--stat', prev, version ] + cmds << [ 'git', 'log', "#{prev}..#{version}" ] + else + cmds << [ 'git', 'log', version ] + end + end + + io.sync = true + cmds.each_with_index do |cmd,i| + i > 0 and io.puts + pid, status = Process.waitpid2(fork do + $stdout.reopen(io) + io.close + exec *cmd + end) + status.success? or abort status.inspect + end + end + + def self.notes(io, opts) + spec = Gem::Specification.load(Dir['*.gemspec'][0]) + io.puts spec.description.strip + io.puts + io.puts "* #{spec.homepage}" + io.puts "* #{spec.email}" + io.puts "* #{opts[:git_url] || opts[:cgit_url]}" + + _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3) + io.print "\nChanges:\n\n" + io.puts body + end +end diff --git a/setup.rb b/setup.rb new file mode 100644 index 0000000..5eb5006 --- /dev/null +++ b/setup.rb @@ -0,0 +1,1586 @@ +# -*- encoding: binary -*- +# +# setup.rb +# +# Copyright (c) 2000-2005 Minero Aoki +# +# This program is free software. +# You can distribute/modify this program under the terms of +# the GNU LGPL, Lesser General Public License version 2.1. +# + +unless Enumerable.method_defined?(:map) # Ruby 1.4.6 + module Enumerable + alias map collect + end +end + +unless File.respond_to?(:read) # Ruby 1.6 + def File.read(fname) + open(fname) {|f| + return f.read + } + end +end + +unless Errno.const_defined?(:ENOTEMPTY) # Windows? + module Errno + class ENOTEMPTY + # We do not raise this exception, implementation is not needed. + end + end +end + +def File.binread(fname) + open(fname, 'rb') {|f| + return f.read + } +end + +# for corrupted Windows' stat(2) +def File.dir?(path) + File.directory?((path[-1,1] == '/') ? path : path + '/') +end + + +class ConfigTable + + include Enumerable + + def initialize(rbconfig) + @rbconfig = rbconfig + @items = [] + @table = {} + # options + @install_prefix = nil + @config_opt = nil + @verbose = true + @no_harm = false + end + + attr_accessor :install_prefix + attr_accessor :config_opt + + attr_writer :verbose + + def verbose? + @verbose + end + + attr_writer :no_harm + + def no_harm? + @no_harm + end + + def [](key) + lookup(key).resolve(self) + end + + def []=(key, val) + lookup(key).set val + end + + def names + @items.map {|i| i.name } + end + + def each(&block) + @items.each(&block) + end + + def key?(name) + @table.key?(name) + end + + def lookup(name) + @table[name] or setup_rb_error "no such config item: #{name}" + end + + def add(item) + @items.push item + @table[item.name] = item + end + + def remove(name) + item = lookup(name) + @items.delete_if {|i| i.name == name } + @table.delete_if {|name, i| i.name == name } + item + end + + def load_script(path, inst = nil) + if File.file?(path) + MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path + end + end + + def savefile + '.config' + end + + def load_savefile + begin + File.foreach(savefile()) do |line| + k, v = *line.split(/=/, 2) + self[k] = v.strip + end + rescue Errno::ENOENT + setup_rb_error $!.message + "\n#{File.basename($0)} config first" + end + end + + def save + @items.each {|i| i.value } + File.open(savefile(), 'w') {|f| + @items.each do |i| + f.printf "%s=%s\n", i.name, i.value if i.value? and i.value + end + } + end + + def load_standard_entries + standard_entries(@rbconfig).each do |ent| + add ent + end + end + + def standard_entries(rbconfig) + c = rbconfig + + rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) + + major = c['MAJOR'].to_i + minor = c['MINOR'].to_i + teeny = c['TEENY'].to_i + version = "#{major}.#{minor}" + + # ruby ver. >= 1.4.4? + newpath_p = ((major >= 2) or + ((major == 1) and + ((minor >= 5) or + ((minor == 4) and (teeny >= 4))))) + + if c['rubylibdir'] + # V > 1.6.3 + libruby = "#{c['prefix']}/lib/ruby" + librubyver = c['rubylibdir'] + librubyverarch = c['archdir'] + siteruby = c['sitedir'] + siterubyver = c['sitelibdir'] + siterubyverarch = c['sitearchdir'] + elsif newpath_p + # 1.4.4 <= V <= 1.6.3 + libruby = "#{c['prefix']}/lib/ruby" + librubyver = "#{c['prefix']}/lib/ruby/#{version}" + librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" + siteruby = c['sitedir'] + siterubyver = "$siteruby/#{version}" + siterubyverarch = "$siterubyver/#{c['arch']}" + else + # V < 1.4.4 + libruby = "#{c['prefix']}/lib/ruby" + librubyver = "#{c['prefix']}/lib/ruby/#{version}" + librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" + siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" + siterubyver = siteruby + siterubyverarch = "$siterubyver/#{c['arch']}" + end + parameterize = lambda {|path| + path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') + } + + if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } + makeprog = arg.sub(/'/, '').split(/=/, 2)[1] + else + makeprog = 'make' + end + + [ + ExecItem.new('installdirs', 'std/site/home', + 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ + {|val, table| + case val + when 'std' + table['rbdir'] = '$librubyver' + table['sodir'] = '$librubyverarch' + when 'site' + table['rbdir'] = '$siterubyver' + table['sodir'] = '$siterubyverarch' + when 'home' + setup_rb_error '$HOME was not set' unless ENV['HOME'] + table['prefix'] = ENV['HOME'] + table['rbdir'] = '$libdir/ruby' + table['sodir'] = '$libdir/ruby' + end + }, + PathItem.new('prefix', 'path', c['prefix'], + 'path prefix of target environment'), + PathItem.new('bindir', 'path', parameterize.call(c['bindir']), + 'the directory for commands'), + PathItem.new('libdir', 'path', parameterize.call(c['libdir']), + 'the directory for libraries'), + PathItem.new('datadir', 'path', parameterize.call(c['datadir']), + 'the directory for shared data'), + PathItem.new('mandir', 'path', parameterize.call(c['mandir']), + 'the directory for man pages'), + PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), + 'the directory for system configuration files'), + PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), + 'the directory for local state data'), + PathItem.new('libruby', 'path', libruby, + 'the directory for ruby libraries'), + PathItem.new('librubyver', 'path', librubyver, + 'the directory for standard ruby libraries'), + PathItem.new('librubyverarch', 'path', librubyverarch, + 'the directory for standard ruby extensions'), + PathItem.new('siteruby', 'path', siteruby, + 'the directory for version-independent aux ruby libraries'), + PathItem.new('siterubyver', 'path', siterubyver, + 'the directory for aux ruby libraries'), + PathItem.new('siterubyverarch', 'path', siterubyverarch, + 'the directory for aux ruby binaries'), + PathItem.new('rbdir', 'path', '$siterubyver', + 'the directory for ruby scripts'), + PathItem.new('sodir', 'path', '$siterubyverarch', + 'the directory for ruby extentions'), + PathItem.new('rubypath', 'path', rubypath, + 'the path to set to #! line'), + ProgramItem.new('rubyprog', 'name', rubypath, + 'the ruby program using for installation'), + ProgramItem.new('makeprog', 'name', makeprog, + 'the make program to compile ruby extentions'), + SelectItem.new('shebang', 'all/ruby/never', 'ruby', + 'shebang line (#!) editing mode'), + BoolItem.new('without-ext', 'yes/no', 'no', + 'does not compile/install ruby extentions') + ] + end + private :standard_entries + + def load_multipackage_entries + multipackage_entries().each do |ent| + add ent + end + end + + def multipackage_entries + [ + PackageSelectionItem.new('with', 'name,name...', '', 'ALL', + 'package names that you want to install'), + PackageSelectionItem.new('without', 'name,name...', '', 'NONE', + 'package names that you do not want to install') + ] + end + private :multipackage_entries + + ALIASES = { + 'std-ruby' => 'librubyver', + 'stdruby' => 'librubyver', + 'rubylibdir' => 'librubyver', + 'archdir' => 'librubyverarch', + 'site-ruby-common' => 'siteruby', # For backward compatibility + 'site-ruby' => 'siterubyver', # For backward compatibility + 'bin-dir' => 'bindir', + 'bin-dir' => 'bindir', + 'rb-dir' => 'rbdir', + 'so-dir' => 'sodir', + 'data-dir' => 'datadir', + 'ruby-path' => 'rubypath', + 'ruby-prog' => 'rubyprog', + 'ruby' => 'rubyprog', + 'make-prog' => 'makeprog', + 'make' => 'makeprog' + } + + def fixup + ALIASES.each do |ali, name| + @table[ali] = @table[name] + end + @items.freeze + @table.freeze + @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/ + end + + def parse_opt(opt) + m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}" + m.to_a[1,2] + end + + def dllext + @rbconfig['DLEXT'] + end + + def value_config?(name) + lookup(name).value? + end + + class Item + def initialize(name, template, default, desc) + @name = name.freeze + @template = template + @value = default + @default = default + @description = desc + end + + attr_reader :name + attr_reader :description + + attr_accessor :default + alias help_default default + + def help_opt + "--#{@name}=#{@template}" + end + + def value? + true + end + + def value + @value + end + + def resolve(table) + @value.gsub(%r<\$([^/]+)>) { table[$1] } + end + + def set(val) + @value = check(val) + end + + private + + def check(val) + setup_rb_error "config: --#{name} requires argument" unless val + val + end + end + + class BoolItem < Item + def config_type + 'bool' + end + + def help_opt + "--#{@name}" + end + + private + + def check(val) + return 'yes' unless val + case val + when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes' + when /\An(o)?\z/i, /\Af(alse)\z/i then 'no' + else + setup_rb_error "config: --#{@name} accepts only yes/no for argument" + end + end + end + + class PathItem < Item + def config_type + 'path' + end + + private + + def check(path) + setup_rb_error "config: --#{@name} requires argument" unless path + path[0,1] == '$' ? path : File.expand_path(path) + end + end + + class ProgramItem < Item + def config_type + 'program' + end + end + + class SelectItem < Item + def initialize(name, selection, default, desc) + super + @ok = selection.split('/') + end + + def config_type + 'select' + end + + private + + def check(val) + unless @ok.include?(val.strip) + setup_rb_error "config: use --#{@name}=#{@template} (#{val})" + end + val.strip + end + end + + class ExecItem < Item + def initialize(name, selection, desc, &block) + super name, selection, nil, desc + @ok = selection.split('/') + @action = block + end + + def config_type + 'exec' + end + + def value? + false + end + + def resolve(table) + setup_rb_error "$#{name()} wrongly used as option value" + end + + undef set + + def evaluate(val, table) + v = val.strip.downcase + unless @ok.include?(v) + setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" + end + @action.call v, table + end + end + + class PackageSelectionItem < Item + def initialize(name, template, default, help_default, desc) + super name, template, default, desc + @help_default = help_default + end + + attr_reader :help_default + + def config_type + 'package' + end + + private + + def check(val) + unless File.dir?("packages/#{val}") + setup_rb_error "config: no such package: #{val}" + end + val + end + end + + class MetaConfigEnvironment + def initialize(config, installer) + @config = config + @installer = installer + end + + def config_names + @config.names + end + + def config?(name) + @config.key?(name) + end + + def bool_config?(name) + @config.lookup(name).config_type == 'bool' + end + + def path_config?(name) + @config.lookup(name).config_type == 'path' + end + + def value_config?(name) + @config.lookup(name).config_type != 'exec' + end + + def add_config(item) + @config.add item + end + + def add_bool_config(name, default, desc) + @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) + end + + def add_path_config(name, default, desc) + @config.add PathItem.new(name, 'path', default, desc) + end + + def set_config_default(name, default) + @config.lookup(name).default = default + end + + def remove_config(name) + @config.remove(name) + end + + # For only multipackage + def packages + raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer + @installer.packages + end + + # For only multipackage + def declare_packages(list) + raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer + @installer.packages = list + end + end + +end # class ConfigTable + + +# This module requires: #verbose?, #no_harm? +module FileOperations + + def mkdir_p(dirname, prefix = nil) + dirname = prefix + File.expand_path(dirname) if prefix + $stderr.puts "mkdir -p #{dirname}" if verbose? + return if no_harm? + + # Does not check '/', it's too abnormal. + dirs = File.expand_path(dirname).split(%r<(?=/)>) + if /\A[a-z]:\z/i =~ dirs[0] + disk = dirs.shift + dirs[0] = disk + dirs[0] + end + dirs.each_index do |idx| + path = dirs[0..idx].join('') + Dir.mkdir path unless File.dir?(path) + end + end + + def rm_f(path) + $stderr.puts "rm -f #{path}" if verbose? + return if no_harm? + force_remove_file path + end + + def rm_rf(path) + $stderr.puts "rm -rf #{path}" if verbose? + return if no_harm? + remove_tree path + end + + def remove_tree(path) + if File.symlink?(path) + remove_file path + elsif File.dir?(path) + remove_tree0 path + else + force_remove_file path + end + end + + def remove_tree0(path) + Dir.foreach(path) do |ent| + next if ent == '.' + next if ent == '..' + entpath = "#{path}/#{ent}" + if File.symlink?(entpath) + remove_file entpath + elsif File.dir?(entpath) + remove_tree0 entpath + else + force_remove_file entpath + end + end + begin + Dir.rmdir path + rescue Errno::ENOTEMPTY + # directory may not be empty + end + end + + def move_file(src, dest) + force_remove_file dest + begin + File.rename src, dest + rescue + File.open(dest, 'wb') {|f| + f.write File.binread(src) + } + File.chmod File.stat(src).mode, dest + File.unlink src + end + end + + def force_remove_file(path) + begin + remove_file path + rescue + end + end + + def remove_file(path) + File.chmod 0777, path + File.unlink path + end + + def install(from, dest, mode, prefix = nil) + $stderr.puts "install #{from} #{dest}" if verbose? + return if no_harm? + + realdest = prefix ? prefix + File.expand_path(dest) : dest + realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) + str = File.binread(from) + if diff?(str, realdest) + verbose_off { + rm_f realdest if File.exist?(realdest) + } + File.open(realdest, 'wb') {|f| + f.write str + } + File.chmod mode, realdest + + File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| + if prefix + f.puts realdest.sub(prefix, '') + else + f.puts realdest + end + } + end + end + + def diff?(new_content, path) + return true unless File.exist?(path) + new_content != File.binread(path) + end + + def command(*args) + $stderr.puts args.join(' ') if verbose? + system(*args) or raise RuntimeError, + "system(#{args.map{|a| a.inspect }.join(' ')}) failed" + end + + def ruby(*args) + command config('rubyprog'), *args + end + + def make(task = nil) + command(*[config('makeprog'), task].compact) + end + + def extdir?(dir) + File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb") + end + + def files_of(dir) + Dir.open(dir) {|d| + return d.select {|ent| File.file?("#{dir}/#{ent}") } + } + end + + DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn ) + + def directories_of(dir) + Dir.open(dir) {|d| + return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT + } + end + +end + + +# This module requires: #srcdir_root, #objdir_root, #relpath +module HookScriptAPI + + def get_config(key) + @config[key] + end + + alias config get_config + + # obsolete: use metaconfig to change configuration + def set_config(key, val) + @config[key] = val + end + + # + # srcdir/objdir (works only in the package directory) + # + + def curr_srcdir + "#{srcdir_root()}/#{relpath()}" + end + + def curr_objdir + "#{objdir_root()}/#{relpath()}" + end + + def srcfile(path) + "#{curr_srcdir()}/#{path}" + end + + def srcexist?(path) + File.exist?(srcfile(path)) + end + + def srcdirectory?(path) + File.dir?(srcfile(path)) + end + + def srcfile?(path) + File.file?(srcfile(path)) + end + + def srcentries(path = '.') + Dir.open("#{curr_srcdir()}/#{path}") {|d| + return d.to_a - %w(. ..) + } + end + + def srcfiles(path = '.') + srcentries(path).select {|fname| + File.file?(File.join(curr_srcdir(), path, fname)) + } + end + + def srcdirectories(path = '.') + srcentries(path).select {|fname| + File.dir?(File.join(curr_srcdir(), path, fname)) + } + end + +end + + +class ToplevelInstaller + + Version = '3.4.1' + Copyright = 'Copyright (c) 2000-2005 Minero Aoki' + + TASKS = [ + [ 'all', 'do config, setup, then install' ], + [ 'config', 'saves your configurations' ], + [ 'show', 'shows current configuration' ], + [ 'setup', 'compiles ruby extentions and others' ], + [ 'install', 'installs files' ], + [ 'test', 'run all tests in test/' ], + [ 'clean', "does `make clean' for each extention" ], + [ 'distclean',"does `make distclean' for each extention" ] + ] + + def ToplevelInstaller.invoke + config = ConfigTable.new(load_rbconfig()) + config.load_standard_entries + config.load_multipackage_entries if multipackage? + config.fixup + klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) + klass.new(File.dirname($0), config).invoke + end + + def ToplevelInstaller.multipackage? + File.dir?(File.dirname($0) + '/packages') + end + + def ToplevelInstaller.load_rbconfig + if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } + ARGV.delete(arg) + load File.expand_path(arg.split(/=/, 2)[1]) + $".push 'rbconfig.rb' + else + require 'rbconfig' + end + ::Config::CONFIG + end + + def initialize(ardir_root, config) + @ardir = File.expand_path(ardir_root) + @config = config + # cache + @valid_task_re = nil + end + + def config(key) + @config[key] + end + + def inspect + "#<#{self.class} #{__id__()}>" + end + + def invoke + run_metaconfigs + case task = parsearg_global() + when nil, 'all' + parsearg_config + init_installers + exec_config + exec_setup + exec_install + else + case task + when 'config', 'test' + ; + when 'clean', 'distclean' + @config.load_savefile if File.exist?(@config.savefile) + else + @config.load_savefile + end + __send__ "parsearg_#{task}" + init_installers + __send__ "exec_#{task}" + end + end + + def run_metaconfigs + @config.load_script "#{@ardir}/metaconfig" + end + + def init_installers + @installer = Installer.new(@config, @ardir, File.expand_path('.')) + end + + # + # Hook Script API bases + # + + def srcdir_root + @ardir + end + + def objdir_root + '.' + end + + def relpath + '.' + end + + # + # Option Parsing + # + + def parsearg_global + while arg = ARGV.shift + case arg + when /\A\w+\z/ + setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) + return arg + when '-q', '--quiet' + @config.verbose = false + when '--verbose' + @config.verbose = true + when '--help' + print_usage $stdout + exit 0 + when '--version' + puts "#{File.basename($0)} version #{Version}" + exit 0 + when '--copyright' + puts Copyright + exit 0 + else + setup_rb_error "unknown global option '#{arg}'" + end + end + nil + end + + def valid_task?(t) + valid_task_re() =~ t + end + + def valid_task_re + @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ + end + + def parsearg_no_options + unless ARGV.empty? + task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) + setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" + end + end + + alias parsearg_show parsearg_no_options + alias parsearg_setup parsearg_no_options + alias parsearg_test parsearg_no_options + alias parsearg_clean parsearg_no_options + alias parsearg_distclean parsearg_no_options + + def parsearg_config + evalopt = [] + set = [] + @config.config_opt = [] + while i = ARGV.shift + if /\A--?\z/ =~ i + @config.config_opt = ARGV.dup + break + end + name, value = *@config.parse_opt(i) + if @config.value_config?(name) + @config[name] = value + else + evalopt.push [name, value] + end + set.push name + end + evalopt.each do |name, value| + @config.lookup(name).evaluate value, @config + end + # Check if configuration is valid + set.each do |n| + @config[n] if @config.value_config?(n) + end + end + + def parsearg_install + @config.no_harm = false + @config.install_prefix = '' + while a = ARGV.shift + case a + when '--no-harm' + @config.no_harm = true + when /\A--prefix=/ + path = a.split(/=/, 2)[1] + path = File.expand_path(path) unless path[0,1] == '/' + @config.install_prefix = path + else + setup_rb_error "install: unknown option #{a}" + end + end + end + + def print_usage(out) + out.puts 'Typical Installation Procedure:' + out.puts " $ ruby #{File.basename $0} config" + out.puts " $ ruby #{File.basename $0} setup" + out.puts " # ruby #{File.basename $0} install (may require root privilege)" + out.puts + out.puts 'Detailed Usage:' + out.puts " ruby #{File.basename $0} " + out.puts " ruby #{File.basename $0} [] []" + + fmt = " %-24s %s\n" + out.puts + out.puts 'Global options:' + out.printf fmt, '-q,--quiet', 'suppress message outputs' + out.printf fmt, ' --verbose', 'output messages verbosely' + out.printf fmt, ' --help', 'print this message' + out.printf fmt, ' --version', 'print version and quit' + out.printf fmt, ' --copyright', 'print copyright and quit' + out.puts + out.puts 'Tasks:' + TASKS.each do |name, desc| + out.printf fmt, name, desc + end + + fmt = " %-24s %s [%s]\n" + out.puts + out.puts 'Options for CONFIG or ALL:' + @config.each do |item| + out.printf fmt, item.help_opt, item.description, item.help_default + end + out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" + out.puts + out.puts 'Options for INSTALL:' + out.printf fmt, '--no-harm', 'only display what to do if given', 'off' + out.printf fmt, '--prefix=path', 'install path prefix', '' + out.puts + end + + # + # Task Handlers + # + + def exec_config + @installer.exec_config + @config.save # must be final + end + + def exec_setup + @installer.exec_setup + end + + def exec_install + @installer.exec_install + end + + def exec_test + @installer.exec_test + end + + def exec_show + @config.each do |i| + printf "%-20s %s\n", i.name, i.value if i.value? + end + end + + def exec_clean + @installer.exec_clean + end + + def exec_distclean + @installer.exec_distclean + end + +end # class ToplevelInstaller + + +class ToplevelInstallerMulti < ToplevelInstaller + + include FileOperations + + def initialize(ardir_root, config) + super + @packages = directories_of("#{@ardir}/packages") + raise 'no package exists' if @packages.empty? + @root_installer = Installer.new(@config, @ardir, File.expand_path('.')) + end + + def run_metaconfigs + @config.load_script "#{@ardir}/metaconfig", self + @packages.each do |name| + @config.load_script "#{@ardir}/packages/#{name}/metaconfig" + end + end + + attr_reader :packages + + def packages=(list) + raise 'package list is empty' if list.empty? + list.each do |name| + raise "directory packages/#{name} does not exist"\ + unless File.dir?("#{@ardir}/packages/#{name}") + end + @packages = list + end + + def init_installers + @installers = {} + @packages.each do |pack| + @installers[pack] = Installer.new(@config, + "#{@ardir}/packages/#{pack}", + "packages/#{pack}") + end + with = extract_selection(config('with')) + without = extract_selection(config('without')) + @selected = @installers.keys.select {|name| + (with.empty? or with.include?(name)) \ + and not without.include?(name) + } + end + + def extract_selection(list) + a = list.split(/,/) + a.each do |name| + setup_rb_error "no such package: #{name}" unless @installers.key?(name) + end + a + end + + def print_usage(f) + super + f.puts 'Inluded packages:' + f.puts ' ' + @packages.sort.join(' ') + f.puts + end + + # + # Task Handlers + # + + def exec_config + run_hook 'pre-config' + each_selected_installers {|inst| inst.exec_config } + run_hook 'post-config' + @config.save # must be final + end + + def exec_setup + run_hook 'pre-setup' + each_selected_installers {|inst| inst.exec_setup } + run_hook 'post-setup' + end + + def exec_install + run_hook 'pre-install' + each_selected_installers {|inst| inst.exec_install } + run_hook 'post-install' + end + + def exec_test + run_hook 'pre-test' + each_selected_installers {|inst| inst.exec_test } + run_hook 'post-test' + end + + def exec_clean + rm_f @config.savefile + run_hook 'pre-clean' + each_selected_installers {|inst| inst.exec_clean } + run_hook 'post-clean' + end + + def exec_distclean + rm_f @config.savefile + run_hook 'pre-distclean' + each_selected_installers {|inst| inst.exec_distclean } + run_hook 'post-distclean' + end + + # + # lib + # + + def each_selected_installers + Dir.mkdir 'packages' unless File.dir?('packages') + @selected.each do |pack| + $stderr.puts "Processing the package `#{pack}' ..." if verbose? + Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") + Dir.chdir "packages/#{pack}" + yield @installers[pack] + Dir.chdir '../..' + end + end + + def run_hook(id) + @root_installer.run_hook id + end + + # module FileOperations requires this + def verbose? + @config.verbose? + end + + # module FileOperations requires this + def no_harm? + @config.no_harm? + end + +end # class ToplevelInstallerMulti + + +class Installer + + FILETYPES = %w( bin lib ext data conf man ) + + include FileOperations + include HookScriptAPI + + def initialize(config, srcroot, objroot) + @config = config + @srcdir = File.expand_path(srcroot) + @objdir = File.expand_path(objroot) + @currdir = '.' + end + + def inspect + "#<#{self.class} #{File.basename(@srcdir)}>" + end + + def noop(rel) + end + + # + # Hook Script API base methods + # + + def srcdir_root + @srcdir + end + + def objdir_root + @objdir + end + + def relpath + @currdir + end + + # + # Config Access + # + + # module FileOperations requires this + def verbose? + @config.verbose? + end + + # module FileOperations requires this + def no_harm? + @config.no_harm? + end + + def verbose_off + begin + save, @config.verbose = @config.verbose?, false + yield + ensure + @config.verbose = save + end + end + + # + # TASK config + # + + def exec_config + exec_task_traverse 'config' + end + + alias config_dir_bin noop + alias config_dir_lib noop + + def config_dir_ext(rel) + extconf if extdir?(curr_srcdir()) + end + + alias config_dir_data noop + alias config_dir_conf noop + alias config_dir_man noop + + def extconf + ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt + end + + # + # TASK setup + # + + def exec_setup + exec_task_traverse 'setup' + end + + def setup_dir_bin(rel) + files_of(curr_srcdir()).each do |fname| + update_shebang_line "#{curr_srcdir()}/#{fname}" + end + end + + alias setup_dir_lib noop + + def setup_dir_ext(rel) + make if extdir?(curr_srcdir()) + end + + alias setup_dir_data noop + alias setup_dir_conf noop + alias setup_dir_man noop + + def update_shebang_line(path) + return if no_harm? + return if config('shebang') == 'never' + old = Shebang.load(path) + if old + $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1 + new = new_shebang(old) + return if new.to_s == old.to_s + else + return unless config('shebang') == 'all' + new = Shebang.new(config('rubypath')) + end + $stderr.puts "updating shebang: #{File.basename(path)}" if verbose? + open_atomic_writer(path) {|output| + File.open(path, 'rb') {|f| + f.gets if old # discard + output.puts new.to_s + output.print f.read + } + } + end + + def new_shebang(old) + if /\Aruby/ =~ File.basename(old.cmd) + Shebang.new(config('rubypath'), old.args) + elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby' + Shebang.new(config('rubypath'), old.args[1..-1]) + else + return old unless config('shebang') == 'all' + Shebang.new(config('rubypath')) + end + end + + def open_atomic_writer(path, &block) + tmpfile = File.basename(path) + '.tmp' + begin + File.open(tmpfile, 'wb', &block) + File.rename tmpfile, File.basename(path) + ensure + File.unlink tmpfile if File.exist?(tmpfile) + end + end + + class Shebang + def Shebang.load(path) + line = nil + File.open(path) {|f| + line = f.gets + } + return nil unless /\A#!/ =~ line + parse(line) + end + + def Shebang.parse(line) + cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') + new(cmd, args) + end + + def initialize(cmd, args = []) + @cmd = cmd + @args = args + end + + attr_reader :cmd + attr_reader :args + + def to_s + "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") + end + end + + # + # TASK install + # + + def exec_install + rm_f 'InstalledFiles' + exec_task_traverse 'install' + end + + def install_dir_bin(rel) + install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755 + end + + def install_dir_lib(rel) + install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644 + end + + def install_dir_ext(rel) + return unless extdir?(curr_srcdir()) + install_files rubyextentions('.'), + "#{config('sodir')}/#{File.dirname(rel)}", + 0555 + end + + def install_dir_data(rel) + install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644 + end + + def install_dir_conf(rel) + # FIXME: should not remove current config files + # (rename previous file to .old/.org) + install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644 + end + + def install_dir_man(rel) + install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644 + end + + def install_files(list, dest, mode) + mkdir_p dest, @config.install_prefix + list.each do |fname| + install fname, dest, mode, @config.install_prefix + end + end + + def libfiles + glob_reject(%w(*.y *.output), targetfiles()) + end + + def rubyextentions(dir) + ents = glob_select("*.#{@config.dllext}", targetfiles()) + if ents.empty? + setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" + end + ents + end + + def targetfiles + mapdir(existfiles() - hookfiles()) + end + + def mapdir(ents) + ents.map {|ent| + if File.exist?(ent) + then ent # objdir + else "#{curr_srcdir()}/#{ent}" # srcdir + end + } + end + + # picked up many entries from cvs-1.11.1/src/ignore.c + JUNK_FILES = %w( + core RCSLOG tags TAGS .make.state + .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb + *~ *.old *.bak *.BAK *.orig *.rej _$* *$ + + *.org *.in .* + ) + + def existfiles + glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.'))) + end + + def hookfiles + %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| + %w( config setup install clean ).map {|t| sprintf(fmt, t) } + }.flatten + end + + def glob_select(pat, ents) + re = globs2re([pat]) + ents.select {|ent| re =~ ent } + end + + def glob_reject(pats, ents) + re = globs2re(pats) + ents.reject {|ent| re =~ ent } + end + + GLOB2REGEX = { + '.' => '\.', + '$' => '\$', + '#' => '\#', + '*' => '.*' + } + + def globs2re(pats) + /\A(?:#{ + pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|') + })\z/ + end + + # + # TASK test + # + + TESTDIR = 'test' + + def exec_test + unless File.directory?('test') + $stderr.puts 'no test in this package' if verbose? + return + end + $stderr.puts 'Running tests...' if verbose? + begin + require 'test/unit' + rescue LoadError + setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.' + end + runner = Test::Unit::AutoRunner.new(true) + runner.to_run << TESTDIR + runner.run + end + + # + # TASK clean + # + + def exec_clean + exec_task_traverse 'clean' + rm_f @config.savefile + rm_f 'InstalledFiles' + end + + alias clean_dir_bin noop + alias clean_dir_lib noop + alias clean_dir_data noop + alias clean_dir_conf noop + alias clean_dir_man noop + + def clean_dir_ext(rel) + return unless extdir?(curr_srcdir()) + make 'clean' if File.file?('Makefile') + end + + # + # TASK distclean + # + + def exec_distclean + exec_task_traverse 'distclean' + rm_f @config.savefile + rm_f 'InstalledFiles' + end + + alias distclean_dir_bin noop + alias distclean_dir_lib noop + + def distclean_dir_ext(rel) + return unless extdir?(curr_srcdir()) + make 'distclean' if File.file?('Makefile') + end + + alias distclean_dir_data noop + alias distclean_dir_conf noop + alias distclean_dir_man noop + + # + # Traversing + # + + def exec_task_traverse(task) + run_hook "pre-#{task}" + FILETYPES.each do |type| + if type == 'ext' and config('without-ext') == 'yes' + $stderr.puts 'skipping ext/* by user option' if verbose? + next + end + traverse task, type, "#{task}_dir_#{type}" + end + run_hook "post-#{task}" + end + + def traverse(task, rel, mid) + dive_into(rel) { + run_hook "pre-#{task}" + __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') + directories_of(curr_srcdir()).each do |d| + traverse task, "#{rel}/#{d}", mid + end + run_hook "post-#{task}" + } + end + + def dive_into(rel) + return unless File.dir?("#{@srcdir}/#{rel}") + + dir = File.basename(rel) + Dir.mkdir dir unless File.dir?(dir) + prevdir = Dir.pwd + Dir.chdir dir + $stderr.puts '---> ' + rel if verbose? + @currdir = rel + yield + Dir.chdir prevdir + $stderr.puts '<--- ' + rel if verbose? + @currdir = File.dirname(rel) + end + + def run_hook(id) + path = [ "#{curr_srcdir()}/#{id}", + "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) } + return unless path + begin + instance_eval File.read(path), path, 1 + rescue + raise if $DEBUG + setup_rb_error "hook #{path} failed:\n" + $!.message + end + end + +end # class Installer + + +class SetupError < StandardError; end + +def setup_rb_error(msg) + raise SetupError, msg +end + +if $0 == __FILE__ + begin + ToplevelInstaller.invoke + rescue SetupError + raise if $DEBUG + $stderr.puts $!.message + $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." + exit 1 + end +end diff --git a/wrongdoc.gemspec b/wrongdoc.gemspec new file mode 100644 index 0000000..970c004 --- /dev/null +++ b/wrongdoc.gemspec @@ -0,0 +1,27 @@ +# -*- encoding: binary -*- +ENV["VERSION"] or abort "VERSION= must be specified" +manifest = File.readlines('.manifest').map! { |x| x.chomp! } +$LOAD_PATH << 'lib' +require 'wrongdoc' +extend Wrongdoc::Gemspec +name, summary, title = readme_metadata + +Gem::Specification.new do |s| + s.name = %q{wrongdoc} + s.version = ENV["VERSION"].dup + s.authors = ["#{name} hackers"] + s.date = Time.now.utc.strftime('%Y-%m-%d') + s.description = readme_description + s.email = %q{wrongdoc@librelist.org} + s.executables = %w(wrongdoc) + s.extra_rdoc_files = extra_rdoc_files(manifest) + s.files = manifest + s.homepage = Wrongdoc.config[:rdoc_url] + s.summary = summary + s.rdoc_options = rdoc_options + s.require_paths = %w(lib) + s.rubyforge_project = %q{rainbows} + s.add_dependency(%q, ['~> 1.4.4']) + s.add_dependency(%q, ['~> 0.1.3']) + s.add_dependency(%q, ['~> 3.0.1']) +end diff --git a/wrongdoc_1 b/wrongdoc_1 new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-24-ge0c7