1 //  Hyperlink Function  ------------------------------------------//
2 
3 //  Copyright (c) 2015 Brandon Cordes
4 //  Distributed under the Boost Software License, Version 1.0.
5 //  (See accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 
8 #ifndef FUNCTION_HYPER_HPP
9 #define FUNCTION_HYPER_HPP
10 
11 #include "inspector.hpp"
12 #include "boost/filesystem/path.hpp"
13 #include <hpx/config/defines.hpp>
14 #include <string>
15 
16 using boost::filesystem::path;
17 
18 //When you have a specific line and the line is the location of the link
linelink(const path & full_path,std::string linenumb)19 inline std::string linelink(const path & full_path, std::string linenumb)
20 {
21     std::string commit = HPX_HAVE_GIT_COMMIT;
22     std::string location = boost::inspect::relative_to(
23         full_path, boost::inspect::search_root_path() );
24     //The erase function for location is to get rid of the first /hpx that will always
25     //be present in any full path this tool is used for (repeated in wordlink and
26     // loclink)
27     std::string total = "<a href = \"https://github.com/STEllAR-GROUP/hpx/blob/"
28         + commit + location + "#L" + linenumb + "\">";
29     total = total + linenumb;
30     total = total + "</a>";
31     return total;
32 }
33 //When you have a specific line, but a word is the location of the link
wordlink(const path & full_path,std::string linenumb,std::string word)34 inline std::string wordlink(const path & full_path,
35     std::string linenumb, std::string word)
36 {
37     std::string commit = HPX_HAVE_GIT_COMMIT;
38     std::string location = boost::inspect::relative_to(
39         full_path, boost::inspect::search_root_path() );
40     std::string total = "<a href = \"https://github.com/STEllAR-GROUP/hpx/blob/"
41         + commit + location + "#L" + linenumb + "\">";
42     total = total + word;
43     total = total + "</a>";
44     return total;
45 }
46 //When you don't have a specific line
loclink(const path & full_path,std::string word)47 inline std::string loclink(const path & full_path, std::string word)
48 {
49     std::string commit = HPX_HAVE_GIT_COMMIT;
50     std::string location = boost::inspect::relative_to(
51         full_path, boost::inspect::search_root_path() );
52     std::string total = "<a href = \"https://github.com/STEllAR-GROUP/hpx/blob/"
53         + commit + location + "\">";
54     total = total + word;
55     total = total + "</a>";
56     return total;
57 }
58 #endif
59