/OOInteraction/src/commands/CDoxygen.cpp

https://github.com/dimitar-asenov/Envision · C++ · 63 lines · 27 code · 11 blank · 25 comment · 0 complexity · 6024ac5975f0d30b11996bce1ec997e3 MD5 · raw file

  1. /***********************************************************************************************************************
  2. **
  3. ** Copyright (c) 2011, 2014 ETH Zurich
  4. ** All rights reserved.
  5. **
  6. ** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
  7. ** following conditions are met:
  8. **
  9. ** * Redistributions of source code must retain the above copyright notice, this list of conditions and the
  10. ** following disclaimer.
  11. ** * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  12. ** following disclaimer in the documentation and/or other materials provided with the distribution.
  13. ** * Neither the name of the ETH Zurich nor the names of its contributors may be used to endorse or promote products
  14. ** derived from this software without specific prior written permission.
  15. **
  16. **
  17. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  18. ** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. **
  25. **********************************************************************************************************************/
  26. #include "CDoxygen.h"
  27. #include "OOInteraction/src/DoxygenWholeTreeVisitor.h"
  28. namespace OOInteraction {
  29. CDoxygen::CDoxygen() : CreateNamedObjectWithAttributes{"doxygen", {{}}}
  30. {
  31. }
  32. Interaction::CommandResult* CDoxygen::executeNamed(Visualization::Item* source, Visualization::Item* /*target*/,
  33. const std::unique_ptr<Visualization::Cursor>&, const QString& /*name*/, const QStringList& /*attributes*/)
  34. {
  35. QDir dir{QDir::currentPath()};
  36. dir.mkpath("doxygen/html/images");
  37. auto aDoxyVisitor = new OOInteraction::DoxygenWholeTreeVisitor{};
  38. QString valDoxy = aDoxyVisitor->visit(source->node()->root());
  39. delete aDoxyVisitor;
  40. QFile file{QDir::currentPath() + "/doxygen/doxy.cpp"};
  41. file.open(QIODevice::WriteOnly | QIODevice::Text);
  42. QTextStream out{&file};
  43. out << valDoxy;
  44. file.close();
  45. QProcess aProcess;
  46. aProcess.setWorkingDirectory(QDir::currentPath() + "/doxygen");
  47. aProcess.start("doxygen", QStringList{});
  48. aProcess.waitForFinished();
  49. QDesktopServices::openUrl(QUrl{QDir::currentPath() + "/doxygen/html/index.html"});
  50. return new Interaction::CommandResult{};
  51. }
  52. }