@@ -196,7 +196,7 @@ util::Graph::Subgraph PythonDiagram::getFileSubgraph(util::Graph& graph_, const
196196 const std::string pathColor = (pyname.is_builtin && pyname.is_definition ) ? " dodgerblue" : " limegreen" ;
197197 const std::string coloredLabel =
198198 " <table border=\" 0\" cellborder=\" 0\" ><tr><td bgcolor=\" " + pathColor + " \" >" +
199- fileInfo.path +
199+ getRelativePath ( fileInfo.path ) +
200200 " </td></tr></table>" ;
201201 graph_.setSubgraphAttribute (subgraph, " label" , coloredLabel, true );
202202
@@ -226,7 +226,8 @@ util::Graph::Node PythonDiagram::addPYNameNode(util::Graph& graph_, const model:
226226util::Graph::Node PythonDiagram::addFileNode (util::Graph& graph_, const core::FileInfo& fileInfo)
227227{
228228 util::Graph::Node node = graph_.getOrCreateNode (" f" + fileInfo.id );
229- graph_.setNodeAttribute (node, " label" , fileInfo.path );
229+ const std::string path = getRelativePath (fileInfo.path );
230+ graph_.setNodeAttribute (node, " label" , path);
230231
231232 return node;
232233}
@@ -242,7 +243,8 @@ util::Graph::Node PythonDiagram::addFileNode(util::Graph& graph_, const core::Fi
242243 const std::string id = (nodeType == ImportedFilePathNode || nodeType == ImportedBuiltinFilePathNode) ? " d" + fileInfo.id : " s" + fileInfo.id ;
243244
244245 util::Graph::Node node = graph_.getOrCreateNode (id);
245- graph_.setNodeAttribute (node, " label" , fileInfo.path );
246+ const std::string path = getRelativePath (fileInfo.path );
247+ graph_.setNodeAttribute (node, " label" , path);
246248 decorateNode (graph_, node, nodeType);
247249
248250 if (nodeType == ImportedFilePathNode || nodeType == ImportedBuiltinFilePathNode) {
@@ -494,6 +496,27 @@ std::string PythonDiagram::getClassTable(const model::PYName& pyname)
494496 label += " </table>" ;
495497 return label;
496498}
499+
500+ std::string PythonDiagram::getRelativePath (const std::string& path)
501+ {
502+ std::map<std::string, std::string> labels;
503+ m_projectService.getLabels (labels);
504+
505+ if (labels.count (" src" )) {
506+ std::string projectPath = labels[" src" ];
507+ std::string projectPathWithSlash = labels[" src" ] + " /" ;
508+
509+ if (path.substr (0 , projectPathWithSlash.size ()) == projectPathWithSlash) {
510+ return path.substr (projectPathWithSlash.size ());
511+ }
512+
513+ if (path.substr (0 , projectPath.size ()) == projectPath) {
514+ return path.substr (projectPath.size ());
515+ }
516+ }
517+
518+ return path;
519+ }
497520} // language
498521} // service
499522} // cc
0 commit comments