我在使“ @link”和“ @see”标签适用于内部/嵌套类的构造函数时遇到了问题,希望这里有人能提供帮助。这个简短的示例类在第25行上给出了Javadoc警告,引用了“ Layer()”文档前几行中的“ @link”和(等效)“ @ see”标记。
package bogus;
import javax.swing.JPanel;
public class LayeredPlot extends JPanel {
/**
* Constructor for the plot.
*/
public LayeredPlot() {
}
public static class Layer {
private String name;
/**
* Construct a default layer with a default name. This method calls
* {@link LayeredPlot.Layer#Layer(String)} OR calls == JAVADOC WARNING
* {@link #Layer(String)} OR calls == JAVADOC WARNING
* {@link Layer#Layer(String)} == JAVADOC WARNING
* with a null name to perform the construction. …Run Code Online (Sandbox Code Playgroud) 使用 Python 的 isinstance 方法时,定义两个类(两个单独的文件中的基类“ClassA”和子类“ClassB”)会产生意外结果。输出似乎受到运行时使用的模块名称(命名空间?)的影响(__main__)。此行为出现在 Python 3.8.5 和 3.10.4 上。
文件 ClassA.py 包含:
class ClassA:
def __init__(self, id):
self.id = id
def __str__(self) -> str:
class_name = type(self).__name__
return f"{class_name} WITH id: {self.id}"
def main():
from ClassB import ClassB
id = 42
for i, instance in enumerate([ClassA(id), ClassB(id)]):
label = f"{type(instance).__name__}:"
print("#" * 50)
print(f"{label} type: {type(instance)}")
label = " " * len(label) # Convert label to appropriate number of spaces
is_a = isinstance(instance, ClassA)
is_b = isinstance(instance, ClassB)
print(f"{label} …Run Code Online (Sandbox Code Playgroud)